From: Christian Groessler Date: Wed, 12 Jun 2013 22:54:03 +0000 (+0200) Subject: Add handling of write requests X-Git-Tag: V2.15~223^2~99 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9f8b5668e14ca68c063dce6ce338df9bedcfab7b;p=cc65 Add handling of write requests --- diff --git a/libsrc/atari/shadow_ram_handlers.s b/libsrc/atari/shadow_ram_handlers.s index 9bd9e11c3..8c4400cbc 100644 --- a/libsrc/atari/shadow_ram_handlers.s +++ b/libsrc/atari/shadow_ram_handlers.s @@ -94,7 +94,7 @@ sram_init: .segment "EXTZP" : zeropage zpptr1: .res 2 -zpptr2: .res 2 +;zpptr2: .res 2 .segment "LOWBUFS" @@ -195,17 +195,6 @@ CIOV_call: rts - - -CIO_write: - lda ICBLL,x - ora ICBLH,x - beq CIO_call_a ; special I/O through A register in case buffer length is 0 - - ;... - bne CIO_call_a - - ; CIO handler ; We have buffer pointer and length entries in the IOCB, but their ; usage depends on the function. @@ -220,9 +209,6 @@ CIO_write: my_CIOV: - ;jmp CIOV_call - ;brk - ; @@@ TODO: check X for valid IOCB index ((X < $80) and ((X & $F) == 0)) sta CIO_a @@ -235,7 +221,7 @@ my_CIOV: cmp #PUTREC bcc CIO_read ; input (GETREC or GETCHR) cmp #CLOSE - bcc CIO_write ; output (PUTREC or PUTCHR) + bcc CIO_write_jmp ; output (PUTREC or PUTCHR) beq CIO_call_a ; pass through, buffer not used cmp #RENAME ; 2 filenames as input parameters in buffer, length not used beq CIO_filename2 @@ -245,12 +231,20 @@ my_CIOV: bcs CIO_call_a ; other commands: assume no buffer ; not reached +CIO_write_jmp: + jmp CIO_write + + +; READ handler +; ------------ CIO_read: lda ICBLL,x ora ICBLH,x beq CIO_call_a ; special I/O through A register in case buffer length is 0 +; @@@ TODO: check if bounce buffer is really needed because buffer is in ROM area + ; If the data length is larger than our bounce buffer, we have to split the request into smaller ones. ; Otherwise we can get away with one call and a copy to the final destination afterwards. @@ -267,16 +261,16 @@ CIO_read: jsr ciobuf_to_iocb jsr CIO_call_a ; call CIO php - bpl no_err + bpl @no_err cpy #EOFERR - beq no_err + beq @no_err pha jsr restore_icba pla plp rts ; return with error -no_err: +@no_err: sta CIO_a sty CIO_y @@ -356,6 +350,7 @@ br_no_err: bne br_done ; update user buffer pointer (zpptr1) + clc lda zpptr1 adc ICBLL,x sta zpptr1 @@ -394,6 +389,149 @@ br_done: +CIO_call_a_jmp: + jmp CIO_call_a + + + +; WRITE handler +; ------------- + + +CIO_write: + lda ICBLL,x + ora ICBLH,x + beq CIO_call_a_jmp ; special I/O through A register in case buffer length is 0 + +; @@@ TODO: check if bounce buffer is really needed because buffer is in ROM area + +; If the data length is larger than our bounce buffer, we have to split the request into smaller ones. +; Otherwise we can get away with a copy to the bounce buffer and the call. + + lda ICBLH,x ; get high byte of length + bne big_write ; not zero -> data too large for our buffers + ; CHANGE HERE TO SUPPORT BOUNCE BUFFERS > 255 BYTES + lda # bounce buffer size? + bcs bw_last ; no, last transfer, use remaining size + + lda #>BUFSZ_CIO + sta ICBLH,x ; set data length + lda # 255 BYTES) - beq copy_done -copy: dey + beq @copy_done +@copy: dey lda CIO_buffer,y sta (zpptr1),y cpy #0 - bne copy -copy_done: + bne @copy +@copy_done: + rts + + +; copy data from user buffer into bounce buffer +; input: X - IOCB index +; zpptr1 - pointer to user buffer +; output: A - destroyed +; Y - 0 +copy_from_user: + ldy ICBLL,x ; get # of bytes to write (CHANGE HERE TO SUPPORT BOUNCE BUFFERS > 255 BYTES) + beq @copy_done +@copy: dey + lda (zpptr1),y + sta CIO_buffer,y + cpy #0 + bne @copy +@copy_done: rts