aboutsummaryrefslogtreecommitdiff
path: root/reloc.s
diff options
context:
space:
mode:
Diffstat (limited to 'reloc.s')
-rw-r--r--reloc.s45
1 files changed, 8 insertions, 37 deletions
diff --git a/reloc.s b/reloc.s
index 857be8f..ed22f13 100644
--- a/reloc.s
+++ b/reloc.s
@@ -1,15 +1,9 @@
;;; reloc.s - relocate code. this is just one puzzle piece.
;;; see README.txt for details.
-; uncomment to enable user-friendly "MEMLO is too high" error.
-; adds ~80 bytes to the code size. also, makes reloc.xex non-relocatable.
-; currently not a problem, but may be in the future.
- ;verbose_memlo_check = 1
-
.export _main
.include "atari.inc"
- ;start_addr = $6c00
start_addr = $71c0
; mkrelocxex.c appends this stuff.
@@ -19,6 +13,7 @@
code_init = end_addr+6
table = end_addr+8
+ ; we use 9 bytes of zero page, in the floating-point area.
zp_addr = FR0
offset_pages = zp_addr ; 1 byte
table_ptr = zp_addr+1 ; 2 bytes
@@ -27,6 +22,7 @@
shfreg = zp_addr+7 ; 1 byte
pagecount = zp_addr+8 ; 1 byte
+ ; "manually" create the atari binary load header.
.org start_addr - 6
.word $ffff
.word start_addr
@@ -49,32 +45,9 @@ calc_offset:
bcs relocate_code
- .ifdef verbose_memlo_check
- ; whoops, MEMLO is too high, print message and wait for keystroke
whoops:
- ldx #0
- lda #<whoops_msg
- sta ICBAL
- lda #>whoops_msg
- sta ICBAL+1
- lda #whoops_len
- sta ICBLL
- stx ICBLH
- lda #PUTCHR
- sta ICCOM
- jsr CIOV
-exitwait:
- lda CH
- cmp #$ff
- beq exitwait
- lda #$ff
- sta CH
- lda #0
- sta COLOR2
- rts
- .else
+ ; whoops, MEMLO is too high!
freeze: bcc freeze ; wait for the user to press Reset.
- .endif
relocate_code:
; adjust addresses while moving the code.
@@ -134,17 +107,20 @@ shiftit:
inx
lda (code_ptr),y
asl shfreg
- bcc dontadj
+ bcc store_byte
sbc offset_pages
-dontadj:
+store_byte:
+ ; store the (possibly adjusted) byte at the destination...
sta (dest_ptr),y
+
iny
bne move_loop
inc code_ptr+1
inc dest_ptr+1
dec pagecount
bne move_loop
+ ;;; end of relocate_code
; bump MEMLO to point one byte past the end of the moved code.
lda code_end
@@ -188,11 +164,6 @@ do_init:
done:
rts
- .ifdef verbose_memlo_check
-whoops_msg: .byte "MEMLO is too high! Press any key to exit.", EOL
- whoops_len = (*-whoops_msg)
- .endif
-
end_addr:
.out .sprintf("reloc.s code size $%04x (%d)", (* - start_addr), (* - start_addr))