mirror of
https://github.com/erkyrath/infocom-zcode-terps.git
synced 2026-03-02 09:46:39 +00:00
189 lines
5.1 KiB
NASM
189 lines
5.1 KiB
NASM
TITLE "Apple ][ YZIP (c)Infocom","RELOCATED SUBROUTINES"
|
|
;
|
|
; FETCHB - use FPC to get a byte in either aux or main mem
|
|
;
|
|
FETCHBx:
|
|
sta RDBNK,Y ; set bank, lower
|
|
ldy #0 ; gotta use Y
|
|
lda (FPC),Y ; so go get it
|
|
sta RDBNK ; go back to main bank
|
|
rts ; and return
|
|
;
|
|
; ZFETCH - fetch byte at (ZPCPNT),Y - offset from (ZPCPNT)
|
|
;
|
|
ZFETCHx:
|
|
sta RDBNK,X ; set lower bank
|
|
lda (ZPCPNT),Y ; so go get it
|
|
sta RDBNK ; go back to main bank
|
|
rts ; bye
|
|
;
|
|
; MFETCH - fetch byte at (MPCPNT),Y - offset from (MPCPNT)
|
|
;
|
|
MFETCHx:
|
|
sta RDBNK,X ; set bank
|
|
lda (MPCPNT),Y ; so go get it
|
|
sta RDBNK ; go back to main bank
|
|
rts ; bye
|
|
;
|
|
; SAVE_DATA - copy data from [DBUFF] to IOBUFF
|
|
; [Y] must == 0; [X] == DSKBNK; [A] == IOBUFF ($8 or $9)
|
|
;
|
|
sta RDBNK,X ; and select that bank for reading
|
|
sta SAVE_DATA+9 ; show which part of iobuff
|
|
SDAT1:
|
|
lda (DBUFF),Y ; get me that byte
|
|
SDAT2:
|
|
sta IOBUFF,Y ; MODIFIED ABOVE
|
|
iny
|
|
bne SDAT1
|
|
sta RDBNK+MAIN ; and back to main
|
|
rts
|
|
RLCLEN EQU $-FETCHBx-1 ; mark length
|
|
;
|
|
; Copy Line
|
|
; SPC - source pointer
|
|
; FPC - destination pointer
|
|
; SPCBNK - bank the above two are talking about
|
|
; LASTL - byte number of ending byte
|
|
; LASTBNK - bank of ending byte
|
|
; STMASK - mask to use on first byte (0 if none)
|
|
; ENDMASK - mask to use for end byte (0 if none)
|
|
CPYx EQU *
|
|
|
|
ldx SPCBNK ; set up banks for first byte
|
|
sta PAGE2SW,X ; r/w which bank in display mem
|
|
|
|
ldy #0 ; use Y reg
|
|
lda STMASK ; get start mask
|
|
beq CPLOOP ; no start mask, start in middle of loop
|
|
and (FPC),Y ; turn off changing bits, keep good bits
|
|
sta (FPC),Y ; save it
|
|
lda STMASK ; get changing bits
|
|
eor #$FF ; turn on changing bits
|
|
and (SPC),Y ; get SPC byte
|
|
ora (FPC),Y ; turn them on in destination too
|
|
sta (FPC),Y ; and destiny
|
|
CPLOOP:
|
|
lda CPY_COUNT ; get count
|
|
lsr A ; /2 for number in this bank
|
|
; adc #0 ; pick up carry if there
|
|
tax ; put in X for indexing
|
|
beq CPLP2 ; then done!
|
|
lda STMASK ; special start?
|
|
beq CPL1 ; nope
|
|
iny ; first one already done
|
|
; dex ; okay, fine
|
|
CPL1:
|
|
lda (SPC),Y ; get byte
|
|
sta (FPC),Y ; store byte
|
|
iny ; next byte
|
|
dex ; count down
|
|
bne CPL1 ; and do it all again
|
|
CPLP2:
|
|
ldy #0 ; reset y
|
|
lda SPCBNK ; get current bank
|
|
eor #1 ; toggle to point to the other one
|
|
tax
|
|
sta PAGE2SW,X
|
|
beq CPLP21 ; we are now in main, things are fine
|
|
iny ; start one more if now in AUX
|
|
CPLP21:
|
|
lda CPY_COUNT ; get count again
|
|
lsr A ; /2 for bytes in this bank
|
|
tax ; put in X for counter
|
|
beq CPDONE ; nothing here
|
|
CPLP2L:
|
|
lda (SPC),Y ; get byte
|
|
sta (FPC),Y ; store byte
|
|
iny ; next byte
|
|
dex ; count byte
|
|
bne CPLP2L ; and swing by again
|
|
CPDONE:
|
|
lda ENDMASK ; do same mucking as when starting
|
|
beq CPEXIT ; no mucking
|
|
pha ; save endmask
|
|
lda CPY_COUNT ; get how many bytes being copied
|
|
and #1 ; odd or even?
|
|
bne CPDONE1 ; if odd, then we are pointing to correct
|
|
ldx SPCBNK ; get original bank
|
|
sta PAGE2SW,X ; and point to it
|
|
CPDONE1:
|
|
pla ; get end mask back
|
|
eor #$FF ; turn on all off bits
|
|
and (FPC),Y ; turn off changing bits
|
|
sta (FPC),Y ; save it
|
|
lda (SPC),Y ; get SPC byte
|
|
and ENDMASK ; turn on changing bits
|
|
ora (FPC),Y ; turn them on in destination too
|
|
sta (FPC),Y ; and destiny
|
|
CPEXIT:
|
|
sta PAGE2SW ; set back to main mem
|
|
rts
|
|
CPYLEN EQU $-CPYx-1
|
|
PAGE3REL:
|
|
;
|
|
; MOUSER - this vectors the call to the correct place
|
|
;
|
|
MOUSERx:
|
|
pha ; save A for a sec
|
|
MSX1: lda MTABLE,X ; get lo part of address
|
|
sta MSVECTOR+LO ; save lo part of address
|
|
pla ; get A back
|
|
nop
|
|
MSX2: ldx #$C4 ; might be changed, depending on slot
|
|
MSX3: ldy #$40 ; hopefully, this doesn't
|
|
jmp (MSVECTOR) ; and away we go
|
|
MSRxLEN EQU $-MOUSERx-1 ; show how long this is
|
|
MSVECTORx:
|
|
ds 1 ; where lo part of vector goes
|
|
MSX4: db $C4 ; slot where mouse is
|
|
MSRLEN EQU $-MOUSERx-1 ; length or routine
|
|
;
|
|
; colors for screen lines
|
|
;
|
|
RADIX 16d
|
|
COLORSx:
|
|
db $00,$00,$00,$00 ; black
|
|
db $08,$11,$22,$44 ; magenta
|
|
db $44,$08,$11,$22 ; brown
|
|
db $4C,$19,$33,$66 ; orange
|
|
db $22,$44,$08,$11 ; dark green
|
|
db $2A,$55,$2A,$55 ; gray 1
|
|
db $66,$4C,$19,$33 ; green
|
|
db $6E,$5D,$3B,$77 ; yellow
|
|
db $11,$22,$44,$08 ; dark blue
|
|
db $19,$33,$66,$4C ; purple
|
|
db $55,$2A,$55,$2A ; gray 2
|
|
db $5D,$3B,$77,$6E ; pink
|
|
db $33,$66,$4C,$19 ; medium blue
|
|
db $3B,$77,$6E,$5D ; light blue
|
|
db $77,$6E,$5D,$3B ; aqua
|
|
db $7F,$7F,$7F,$7F ; white
|
|
XPOSTBLx:
|
|
DB 0
|
|
DB 0,1,1,2,2,3,4
|
|
DB 4,5,5,6,6,7,8
|
|
DB 8,9,9,$0a,$0a,$0b,$0c
|
|
DB $0c,$0d,$0d,$0e,$0e,$0f,$10
|
|
DB $10,$11,$11,$12,$12,$13,$14
|
|
DB $14,$15,$15,$16,$16,$17,$18
|
|
DB $18,$19,$19,$1a,$1a,$1b,$1c
|
|
DB $1c,$1d,$1d,$1e,$1e,$1f,$20
|
|
DB $20,$21,$21,$22,$22,$23,$24
|
|
DB $24,$25,$25,$26,$26,$27,$28
|
|
DB $28,$29,$29,$2a,$2a,$2b,$2c
|
|
DB $2c,$2d,$2d,$2e,$2e,$2f,$30
|
|
DB $30,$31,$31,$32,$32,$33,$34
|
|
DB $34,$35,$35,$36,$36,$37,$38
|
|
DB $38,$39,$39,$3a,$3a,$3b,$3c
|
|
DB $3c,$3d,$3d,$3e,$3e,$3f,$40
|
|
DB $40,$41,$41,$42,$42,$43,$44
|
|
DB $44,$45,$45,$46,$46,$47,$48
|
|
DB $48,$49,$49,$4a,$4a,$4b,$4c
|
|
DB $4c,$4d,$4d,$4e,$4e,$4f,$50
|
|
RADIX 10d
|
|
PAGE3RELL EQU $-PAGE3REL-1
|
|
END
|
|
|
|
|