refactoring: wip: move code segments
This commit is contained in:
parent
51477cff9d
commit
85ac2cf971
6
Makefile
6
Makefile
@ -1,7 +1,7 @@
|
||||
.POSIX:
|
||||
|
||||
ASM=$(wildcard src/*.asm)
|
||||
RES=res.bin/amour.sid res.bin/levels.bin res.bin/unlzg.bin
|
||||
RES=res.bin/amour2.sid res.bin/levels.bin res.bin/unlzg.bin
|
||||
|
||||
.PHONY: debug env clean all
|
||||
|
||||
@ -43,8 +43,8 @@ env:
|
||||
bin/explodefont: util/explodefont.cpp
|
||||
g++ -o bin/explodefont util/explodefont.cpp
|
||||
|
||||
res.bin/amour.sid:
|
||||
cp res.org/amour.sid res.bin/amour.sid
|
||||
res.bin/amour2.sid:
|
||||
cp res.org/amour2.sid res.bin/amour2.sid
|
||||
|
||||
res.bin/levels.bin: bin/level res.org/levels.txt
|
||||
bin/level < res.org/levels.txt > res.bin/levels.bin
|
||||
|
Binary file not shown.
BIN
res.org/amour2.sid
Normal file
BIN
res.org/amour2.sid
Normal file
Binary file not shown.
@ -2,11 +2,10 @@
|
||||
|
||||
SEG.U zeropageSegment
|
||||
org $02
|
||||
INCLUDE "zeropage.asm"
|
||||
|
||||
SEG cartridgeSegment
|
||||
SEG loaderSegment
|
||||
org $8000
|
||||
|
||||
SEG loaderSegment
|
||||
cartridge SUBROUTINE
|
||||
WORD .coldstart
|
||||
WORD .warmstart
|
||||
@ -55,4 +54,3 @@ cartridge SUBROUTINE
|
||||
; force filler for the *PROM
|
||||
. = $9fff
|
||||
BYTE #$ff
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
LASTINIT SET .
|
||||
#endif
|
||||
|
||||
SEG programSegment
|
||||
statusPlay: ; do Game
|
||||
; Check counter
|
||||
ldx irqn
|
||||
|
@ -2,6 +2,12 @@
|
||||
LASTINIT SET .
|
||||
#endif
|
||||
|
||||
SEG zeropageSegment
|
||||
; Generic src/dst copy pointers
|
||||
srcPointer DS 2
|
||||
dstPointer DS 2
|
||||
|
||||
SEG programSegment
|
||||
introreset SUBROUTINE
|
||||
jsr multicolorOff
|
||||
|
||||
@ -425,7 +431,7 @@ statusMenuReset SUBROUTINE
|
||||
|
||||
; Print Game Title: big "SNAKE"
|
||||
; color first
|
||||
MEMSET #$d800, #$02, #200
|
||||
MEMSET #$d800, #$02, #150
|
||||
; actual "text"
|
||||
lda #$00
|
||||
sta dstPointer
|
||||
@ -514,6 +520,11 @@ SnakeText:
|
||||
HEX 80 80 80 80 80 80 80 80 80 80 80 a0 80 a0 80 80 a0 80 a0 80 80 a0 80 a0 a0 f7 80 a0 80 80 80 80 80 80 80 80 80 80 80 80
|
||||
HEX 80 80 80 80 80 80 80 80 f6 a0 a0 f9 80 f8 80 80 f8 80 f9 80 80 f8 80 a0 f8 f9 80 f8 a0 a0 f7 80 80 80 80 80 80 80 80 80
|
||||
|
||||
;ParabolicSpaceChars:
|
||||
; HEX 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
;ParabolicSpaceScroll:
|
||||
; HEX 00 01 01 01 01 01 01 01 02 02 02 03 03 04 04 05 06 06 07 00 00 01 02 03 04 05 06 07 00 01 02 04 05 06 00 01 02 04 05 07 00 02 04 05 07 00 01 03 04 06 00 01 03 04 06 07 00 02 03 04 06 07 00 01 02 03 04 05 06 07 00 01 02 02 03 04 04 05 05 06 06 06 07 06 07 07 07 07 07 07 07
|
||||
|
||||
setupXScrollInterrupt SUBROUTINE
|
||||
ldx #<XScrollInterruptH
|
||||
ldy #>XScrollInterruptH
|
||||
|
@ -2,6 +2,12 @@
|
||||
LASTINIT SET .
|
||||
#endif
|
||||
|
||||
SEG zeropageSegment
|
||||
; Pointer to video memory used in the level loading routine
|
||||
levelVideoPointer WORD
|
||||
levelColorPointer WORD
|
||||
|
||||
SEG programSegment
|
||||
; load new level on the screen
|
||||
statusLevelTitle SUBROUTINE
|
||||
jsr multicolorOff
|
||||
|
@ -1,10 +1,9 @@
|
||||
processor 6502
|
||||
|
||||
SEG.U
|
||||
SEG.U zeropageSegment
|
||||
org $02
|
||||
INCLUDE "zeropage.asm"
|
||||
|
||||
SEG autostart
|
||||
SEG loaderSegment
|
||||
org $801
|
||||
autostartRoutine SUBROUTINE
|
||||
; this is at $801
|
||||
@ -50,6 +49,7 @@ autostartRoutine SUBROUTINE
|
||||
|
||||
; DATA
|
||||
; -------------------------------------
|
||||
SEG loaderSegment
|
||||
packFileName:
|
||||
BYTE "PACKLZ"
|
||||
packFileNameEnd:
|
||||
|
106
src/lzgmini.asm
106
src/lzgmini.asm
@ -1,44 +1,48 @@
|
||||
inflate SUBROUTINE
|
||||
.inEnd EQU 2
|
||||
.offset EQU 4
|
||||
.length EQU 6
|
||||
.symbol EQU 25
|
||||
.marker1 EQU 30
|
||||
.marker2 EQU 31
|
||||
.marker3 EQU 32
|
||||
.marker4 EQU 33
|
||||
.copy EQU 34
|
||||
SEG zeropageSegment
|
||||
srcPointer WORD
|
||||
dstPointer WORD
|
||||
inEnd WORD
|
||||
offset WORD
|
||||
length BYTE
|
||||
symbol BYTE
|
||||
marker1 BYTE
|
||||
marker2 BYTE
|
||||
marker3 BYTE
|
||||
marker4 BYTE
|
||||
copy WORD
|
||||
|
||||
SEG loaderSegment
|
||||
inflate SUBROUTINE
|
||||
clc
|
||||
ldy #10
|
||||
lda (srcPointer),y
|
||||
adc srcPointer
|
||||
sta .inEnd
|
||||
sta inEnd
|
||||
dey
|
||||
lda (srcPointer),y
|
||||
adc srcPointer + 1
|
||||
sta .inEnd + 1
|
||||
sta inEnd + 1
|
||||
clc
|
||||
lda .inEnd
|
||||
lda inEnd
|
||||
adc #16
|
||||
sta .inEnd
|
||||
lda .inEnd + 1
|
||||
sta inEnd
|
||||
lda inEnd + 1
|
||||
adc #0
|
||||
sta .inEnd + 1
|
||||
sta inEnd + 1
|
||||
|
||||
; Get the marker symbols
|
||||
ldy #16
|
||||
lda (srcPointer),y
|
||||
sta .marker1
|
||||
sta marker1
|
||||
iny
|
||||
lda (srcPointer),y
|
||||
sta .marker2
|
||||
sta marker2
|
||||
iny
|
||||
lda (srcPointer),y
|
||||
sta .marker3
|
||||
sta marker3
|
||||
iny
|
||||
lda (srcPointer),y
|
||||
sta .marker4
|
||||
sta marker4
|
||||
|
||||
; Skip header + marker symbols (16 + 4 bytes)
|
||||
clc
|
||||
@ -53,30 +57,30 @@ inflate SUBROUTINE
|
||||
ldy #0 ; Make sure that Y is zero
|
||||
.mainloop:
|
||||
lda srcPointer ; done?
|
||||
cmp .inEnd
|
||||
cmp inEnd
|
||||
bne .notdone
|
||||
lda srcPointer + 1
|
||||
cmp .inEnd + 1
|
||||
cmp inEnd + 1
|
||||
bne .notdone
|
||||
rts
|
||||
.notdone:
|
||||
lda (srcPointer),y ; A = symbol
|
||||
sta .symbol
|
||||
sta symbol
|
||||
sta $d020
|
||||
inc srcPointer
|
||||
bne .noinc1
|
||||
inc srcPointer + 1
|
||||
.noinc1:
|
||||
cmp .marker1 ; Marker1?
|
||||
cmp marker1 ; Marker1?
|
||||
beq .domarker1
|
||||
cmp .marker2 ; Marker2?
|
||||
cmp marker2 ; Marker2?
|
||||
beq .domarker2
|
||||
cmp .marker3 ; Marker3?
|
||||
cmp marker3 ; Marker3?
|
||||
beq .domarker3
|
||||
cmp .marker4 ; Marker4?
|
||||
cmp marker4 ; Marker4?
|
||||
beq .domarker4
|
||||
.literal:
|
||||
lda .symbol
|
||||
lda symbol
|
||||
sta (dstPointer),y ; Plain copy
|
||||
inc dstPointer
|
||||
bne .mainloop
|
||||
@ -101,15 +105,15 @@ inflate SUBROUTINE
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta .offset
|
||||
inc .offset
|
||||
sta offset
|
||||
inc offset
|
||||
lda #0
|
||||
sta .offset + 1 ; offset = (b >> 5) + 1
|
||||
sta offset + 1 ; offset = (b >> 5) + 1
|
||||
txa
|
||||
and #$1f
|
||||
tax
|
||||
lda .LZG_LENGTH_DECODE_LUT,x
|
||||
sta .length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
sta length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
jmp .docopy
|
||||
|
||||
; marker3 - "Short copy"
|
||||
@ -130,13 +134,13 @@ inflate SUBROUTINE
|
||||
lsr
|
||||
clc
|
||||
adc #3
|
||||
sta .length ; length = (b >> 6) + 3
|
||||
sta length ; length = (b >> 6) + 3
|
||||
txa
|
||||
and #$3f
|
||||
adc #8
|
||||
sta .offset
|
||||
sta offset
|
||||
lda #0
|
||||
sta .offset + 1 ; offset = (b & 0x3f) + 8
|
||||
sta offset + 1 ; offset = (b & 0x3f) + 8
|
||||
beq .docopy
|
||||
|
||||
; marker2 - "Medium copy"
|
||||
@ -154,7 +158,7 @@ inflate SUBROUTINE
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta .offset + 1
|
||||
sta offset + 1
|
||||
lda (srcPointer),y
|
||||
inc srcPointer
|
||||
bne .noinc6
|
||||
@ -162,15 +166,15 @@ inflate SUBROUTINE
|
||||
.noinc6:
|
||||
clc
|
||||
adc #8
|
||||
sta .offset
|
||||
sta offset
|
||||
bcc .noinc7
|
||||
inc .offset + 1 ; offset = (((b & 0xe0) << 3) | b2) + 8
|
||||
inc offset + 1 ; offset = (((b & 0xe0) << 3) | b2) + 8
|
||||
.noinc7:
|
||||
txa
|
||||
and #$1f
|
||||
tax
|
||||
lda .LZG_LENGTH_DECODE_LUT,x
|
||||
sta .length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
sta length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
bne .docopy
|
||||
|
||||
.literal2:
|
||||
@ -188,13 +192,13 @@ inflate SUBROUTINE
|
||||
and #$1f
|
||||
tax
|
||||
lda .LZG_LENGTH_DECODE_LUT,x
|
||||
sta .length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
sta length ; length = .LZG_LENGTH_DECODE_LUT[b & 0x1f]
|
||||
lda (srcPointer),y
|
||||
inc srcPointer
|
||||
bne .noinc9
|
||||
inc srcPointer + 1
|
||||
.noinc9:
|
||||
sta .offset + 1
|
||||
sta offset + 1
|
||||
lda (srcPointer),y
|
||||
inc srcPointer
|
||||
bne .noinc10
|
||||
@ -202,31 +206,31 @@ inflate SUBROUTINE
|
||||
.noinc10:
|
||||
clc
|
||||
adc #$08
|
||||
sta .offset
|
||||
lda .offset + 1
|
||||
sta offset
|
||||
lda offset + 1
|
||||
adc #$08
|
||||
sta .offset + 1 ; offset = ((b2 << 8) | (*src++)) + 2056
|
||||
sta offset + 1 ; offset = ((b2 << 8) | (*src++)) + 2056
|
||||
|
||||
; Copy corresponding data from history window
|
||||
.docopy:
|
||||
sec
|
||||
lda dstPointer
|
||||
sbc .offset
|
||||
sta .copy
|
||||
sbc offset
|
||||
sta copy
|
||||
lda dstPointer + 1
|
||||
sbc .offset + 1
|
||||
sta .copy + 1
|
||||
sbc offset + 1
|
||||
sta copy + 1
|
||||
.loop1:
|
||||
lda (.copy),y
|
||||
lda (copy),y
|
||||
sta (dstPointer),y
|
||||
iny
|
||||
cpy .length
|
||||
cpy length
|
||||
bne .loop1
|
||||
ldy #0 ; Make sure that Y is zero
|
||||
|
||||
clc
|
||||
lda dstPointer
|
||||
adc .length
|
||||
adc length
|
||||
sta dstPointer
|
||||
bcc .noinc11
|
||||
inc dstPointer + 1
|
||||
|
@ -1,8 +1,6 @@
|
||||
SEG zeropageSegment
|
||||
ptrDstStart:
|
||||
WORD
|
||||
ptrDstEnd:
|
||||
WORD
|
||||
ptrDstStart WORD
|
||||
ptrDstEnd WORD
|
||||
|
||||
MACRO MEMSET
|
||||
SEG programSegment
|
||||
|
@ -13,7 +13,6 @@
|
||||
; ----------------------------------------------------------------------
|
||||
SEG.U zeropageSegment
|
||||
org $02
|
||||
INCLUDE "zeropage.asm"
|
||||
|
||||
#if VERBOSE = 1
|
||||
; Locations $90-$FF in zeropage are used by kernal
|
||||
@ -74,8 +73,11 @@ sidtune:
|
||||
listX DS 256
|
||||
listY DS 256
|
||||
|
||||
; Includes
|
||||
INCLUDE "zeropage.asm"
|
||||
|
||||
;
|
||||
; coded 2017, 2018, 2019, 2020
|
||||
; coded 2017, 2018, 2019, 2020, 2021
|
||||
; by giomba -- giomba at glgprograms.it
|
||||
; this software is free software and is distributed
|
||||
; under the terms of GNU GPL v3 license
|
||||
|
@ -4,7 +4,12 @@ LASTINIT SET .
|
||||
|
||||
; Subroutines
|
||||
; ----------------------------------------------------------------------
|
||||
SEG zeropageSegment
|
||||
; Where is the snake head in video memory? Do math to calculate address
|
||||
; using pointer at tileMem
|
||||
tileMem WORD
|
||||
|
||||
SEG programSegment
|
||||
; Clear screen -- easy
|
||||
clearScreen SUBROUTINE
|
||||
ldx #$ff
|
||||
@ -91,6 +96,13 @@ printByte SUBROUTINE
|
||||
|
||||
rts
|
||||
|
||||
SEG zeropageSegment
|
||||
; Pointer to string
|
||||
srcStringPointer WORD
|
||||
; Pointer to screen position where to print intro string
|
||||
dstScreenPointer DS 2
|
||||
|
||||
SEG programSegment
|
||||
printString SUBROUTINE
|
||||
; Print string
|
||||
; Input parameters:
|
||||
|
@ -1,31 +1,15 @@
|
||||
; Zero page utility pointers
|
||||
; ----------------------------------------------------------------------
|
||||
; Where is the snake head in video memory? Do math to calculate address
|
||||
; using pointer at tileMem,tileMem+1
|
||||
tileMem DS 2
|
||||
|
||||
; Pointer to string
|
||||
srcStringPointer DS 2
|
||||
; Pointer to screen position where to print intro string
|
||||
dstScreenPointer DS 2
|
||||
|
||||
SEG zeropageSegment
|
||||
; Pointer to level struct
|
||||
levelPointer DS 2
|
||||
|
||||
; Pointer to video memory used in the level loading routine
|
||||
levelVideoPointer DS 2
|
||||
levelColorPointer DS 2
|
||||
|
||||
; Pointer for Pointer in the NextPointer routine
|
||||
nextPointerPointer DS 2
|
||||
|
||||
; Pointer to string for strlen routine
|
||||
strlenString DS 2
|
||||
|
||||
; Generic src/dst copy pointers
|
||||
srcPointer DS 2
|
||||
dstPointer DS 2
|
||||
|
||||
; Interrupt counter
|
||||
counter DS 2
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user