Skip to content

Commit

Permalink
[KERNAL] halt before clobbering I/O space when LOADing through $9EFF
Browse files Browse the repository at this point in the history
  • Loading branch information
mooinglemur committed Mar 22, 2024
1 parent 60e6d7c commit 0b9949a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions kernal/cbm/channel/errorhandler.s
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ error7 lda #7 ;not output file
error8 lda #8 ;missing file name
bra :+
error9 lda #9 ;bad device #
bra :+
error16
lda #16 ;out of memory
;
: pha ;error number on stack
jsr clrch ;restore i/o channels
Expand Down
12 changes: 11 additions & 1 deletion kernal/cbm/channel/load.s
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ bld12:
ldx verck ; check mode for VRAM
bpl @skip ; don't do bank check if VRAM (RAM: verck=$FF)
cpy #$a0
bcc @skip ;below banked RAM
bcc @lowram ;below banked RAM
cpy #$c0
bcs @skip ;above banked RAM
@loop cmp #$c0
bcc @skip
sbc #$20
bra @loop
@lowram
cmp #$9d ;if we're about to clobber I/O space, slow down
bcs ld39 ;read one byte at a time from here on out
@skip
sta eah
bit status ;eoi?
Expand All @@ -174,6 +177,7 @@ ld35
sta VERA_ADDR_M ;set address bits 15:8
bra bld10 ; attempt block read using macptr
;
ld39 sta eah
ld40 lda #$fd ;mask off timeout
and status
sta status
Expand Down Expand Up @@ -216,6 +220,8 @@ ld60 inc eal ;increment store addr
;if necessary, wrap to next bank
;
lda eah
cmp #$9f ;I/O space?
beq ld81 ;return "out of memory" if loading to RAM
cmp #$c0 ;reached top of high ram?
bne ld64 ;no
lda verck ;check mode
Expand Down Expand Up @@ -246,6 +252,10 @@ ld80 ldx eal
ldy eah
lda #0
rts
ld81 lda verck
dec
beq ld64 ; loading to VRAM
jmp error16 ;"out of memory", tried to load or verify into I/O space

;subroutine to print to console:
;
Expand Down

0 comments on commit 0b9949a

Please sign in to comment.