Login
Back to forumSee the full topicGo to last reply

Posted By

Harry Potter
on 2022-07-07
13:36:11
 Plus4Cart3 bug

Hi! I am working hard on my Plus4/cc65 cartridge library and am having a problem: while printing text to the screen, the program stops in the middle of the process. sad I don't know what's causing this. Following is the write.s file as included in the library:

---------------------
.proc _write

jsr rwcommon ; Pop params, check handle
bcs invalidfd ; Invalid handle

; Check if the LFN is valid and the file is open for writing

adc #LFN_OFFS ; Carry is already clear
tax
lda fdtab-LFN_OFFS,x; Get flags for this handle
and #LFN_WRITE ; File open for writing?
beq invalidfd

; Valid lfn. Make it the output file

jsr CKOUT
bcc @L2
@error: jmp __mappederrno ; Store into __oserror, map to errno, return -1

; Output the next character from the buffer

@L0: ldy #0
lda (ptr1),y
inc ptr1
bne @L1
inc ptr1+1 ; A = *buf++;
@L1: jsr BSOUT

; Check the status

pha
jsr READST
lsr a ; Bit zero is write timeout
bne devnotpresent2
pla
bcs @L3

; Count characters written

inc ptr3
bne @L2
inc ptr3+1

; Decrement count

@L2: dec ptr2
bne @L0
dec ptr2+1
bne @L0

; Wrote all chars or disk full. Close the output channel

@L3: jsr CLRCH

; Clear _oserror and return the number of chars written

lda #0
sta __oserror
lda ptr3
ldx ptr3+1
rts

; Error entry: Device not present

devnotpresent2:
pla
devnotpresent:
lda #ENODEV
.byte $2C ; Skip next opcode via BIT

; Error entry: The given file descriptor is not valid or not open

invalidfd:
lda #EBADF
jmp __directerrno ; Sets _errno, clears _oserror, returns -1

.endproc
--------------------------------

BTW, IIRC, cgetc() doesn't work either, but getkey() does.



Back to top


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon