provided LINKPRG routine

This commit is contained in:
FeralChild64 committed 2019-10-06 17:06:42 +02:00
1 parent 47fdf8c08c
commit 68b61f4c8c
4 files changed
+91 -90

No files matched your search

+1 -1
View File
@@ -76,7 +76,7 @@ Not all of them - only these we want to have implemented.
| Address | Name | Status | Remarks |
| :-------: | :----------- | :------: | :------------------------------------------------: |
| `$A004` | revision str | DONE | |
| `$A533` | LINKPRG | NOT DONE | |
| `$A533` | LINKPRG | DONE | |
| `$A659` | set txt ptr | NOT DONE | |
| `$A68E` | RUNC | NOT DONE | |
| `$A7AE` | NEWSTT | NOT DONE | |
+88 -3
View File
@@ -1,6 +1,91 @@
// XXX provide documentation and implementation
// see: https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7
//
// Well-known BASIC routine, described in:
//
// - [CM64] Compute's Mapping the Commodore 64 - page 95
// - https://www.lemon64.com/forum/viewtopic.php?t=64721&sid=bc400a5a6d404f8f092e4d32a92f5de7
//
LINKPRG:
STUB_IMPLEMENTATION()
// Start by getting pointer to the first line
jsr init_oldtxt
linkprg_loop:
// Is the pointer to the end of the program
ldy #1
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
bne !+
// End of program
rts
!:
// Now search forward to find the end of the line
// Skip forward pointer and line number
ldy #4
linkprg_end_of_line_search:
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
cmp #$00
beq !+
// Not yet end of line
iny
bne linkprg_end_of_line_search
// line too long
jmp do_STRING_TOO_LONG_error
!:
// Found end of line, so update pointer
// First, skip over the $00 char
iny
// Now overwrite the pointer (carefully)
//
tya
clc
adc OLDTXT+0
pha
php
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (OLDTXT),y
#endif
plp
lda OLDTXT+1
adc #0
ldy #1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (OLDTXT),y
#endif
sta OLDTXT+1
pla
sta OLDTXT+0
jmp linkprg_loop
+1 -85
View File
@@ -112,7 +112,7 @@ got_loadaddress:
// Now relink the loaded program, as we cannot trust the line
// links supplied. For example, the VICE virtual drive emulation
// always supplies $0101 as the address of the next line.
jsr basic_relink_program
jsr LINKPRG
// After LOADing, we either start the program from the beginning,
// or go back to the READY prompt if LOAD was called from direct mode.
@@ -122,87 +122,3 @@ got_loadaddress:
// XXX - should run program if LOAD was used in program mode
jmp basic_main_loop
basic_relink_program:
// Start by getting pointer to the first line
jsr init_oldtxt
basic_relink_loop:
// Is the pointer to the end of the program
ldy #1
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
bne !+
// End of program
rts
!:
// Now search forward to find the end of the line
// Skip forward pointer and line number
ldy #4
end_of_line_search:
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (OLDTXT),y
#endif
cmp #$00
beq !+
// Not yet end of line
iny
bne end_of_line_search
// line too long
jmp do_STRING_TOO_LONG_error
!:
// Found end of line, so update pointer
// First, skip over the $00 char
iny
// Now overwrite the pointer (carefully)
//
tya
clc
adc OLDTXT+0
pha
php
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<OLDTXT+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (OLDTXT),y
#endif
plp
lda OLDTXT+1
adc #0
ldy #1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (OLDTXT),y
#endif
sta OLDTXT+1
pla
sta OLDTXT+0
jmp basic_relink_loop
+1 -1
View File
@@ -142,6 +142,6 @@ load_loop:
lda FA
jsr close_load
.break
// Return last address
jmp lvs_return_last_address