mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-12-01 06:49:59 +00:00
1cca2ca580
mostly updated the required and common libraries, as well as created a minify program in applesoft basic that automatically creates a .min file from fully-commented source.
374 lines
7.4 KiB
Plaintext
374 lines
7.4 KiB
Plaintext
*
|
|
*``````````````````````````````*
|
|
* REQUIRED.LIB *
|
|
*- -*
|
|
* GLOBAL ROUTINES AND *
|
|
* VARIABLES EITHER USED BY THE *
|
|
* LIBRARY OR PROVIDED FOR DEMO *
|
|
* USE OR DEBUGGING PURPOSES. *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
********************************
|
|
* *
|
|
* GLOBAL ROUTINES *
|
|
* *
|
|
********************************
|
|
*
|
|
*``````````````````````````````*
|
|
* __GETRET: GET RETURN *
|
|
*- -*
|
|
* COPIES THE DATA IN [RETURN] *
|
|
* TO THE SPECIFIED LOCATION. *
|
|
* LENGTH IS DETERMINED BY *
|
|
* VALUE OF RETLEN. *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__GETRET
|
|
*
|
|
LDY #255
|
|
PLA
|
|
STA ADDR1
|
|
PLA
|
|
STA ADDR1+1
|
|
*
|
|
:LP
|
|
INY
|
|
LDA RETURN,Y
|
|
STA (ADDR1),Y
|
|
CPY RETLEN
|
|
BNE :LP
|
|
LDA ADDR1+1
|
|
PHA
|
|
LDA ADDR1
|
|
PHA
|
|
RTS
|
|
*
|
|
*``````````````````````````````*
|
|
* __SETPARM: SET PARAMETER *
|
|
*- -*
|
|
* COPIES DATA FROM SPECIFIED *
|
|
* ADDRESS TO THE [PARAM] *
|
|
* LOCATION FOR PASSING TO *
|
|
* A ROUTINE. *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__SETPARM
|
|
*
|
|
LDY #255
|
|
PLA
|
|
STA ADDR1
|
|
PLA
|
|
STA ADDR1+1
|
|
*
|
|
:LP
|
|
INY
|
|
LDA (ADDR1),Y
|
|
STA PARAM,Y
|
|
CPY PARLEN
|
|
BNE :LP
|
|
LDA ADDR1+1
|
|
PHA
|
|
LDA ADDR1
|
|
PHA
|
|
RTS
|
|
*
|
|
*``````````````````````````````*
|
|
* __DUMP: DUMP DATA *
|
|
*- -*
|
|
* OUTPUTS DATA LOCATED AT THE *
|
|
* SPECIFIED ADDRESS IN HEX *
|
|
* FORMAT FOR SPECIFIED NUMBER *
|
|
* OF BYTES. *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__DUMP
|
|
*
|
|
PLA
|
|
STA :RET
|
|
PLA
|
|
STA :RET+1
|
|
PLA
|
|
STA :LENGTH
|
|
PLA
|
|
STA ADDR3
|
|
PLA
|
|
STA ADDR3+1
|
|
*
|
|
LDA #$8D
|
|
JSR $FDF0
|
|
LDA ADDR3+1
|
|
AND #$F0
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
TAX
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDA ADDR3+1
|
|
AND #$0F
|
|
TAX
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDA ADDR3
|
|
AND #$F0
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
TAX
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDA ADDR3
|
|
AND #$0F
|
|
TAX
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDA #186 ; :
|
|
JSR $FDF0
|
|
LDA #160 ; SPC
|
|
JSR $FDF0
|
|
*
|
|
LDY #0
|
|
:LP
|
|
LDA (ADDR3),Y
|
|
AND #$F0 ; MASK RIGHT
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
STA :LEFT
|
|
LDA (ADDR3),Y
|
|
AND #$0F ; MASK LEFT
|
|
STA :RIGHT
|
|
LDX :LEFT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDX :RIGHT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDA #160
|
|
JSR $FDF0
|
|
INY
|
|
CPY :LENGTH
|
|
BNE :LP
|
|
*
|
|
*LDA #$8D
|
|
*JSR $FDF0
|
|
LDA :RET+1
|
|
PHA
|
|
LDA :RET
|
|
PHA
|
|
*
|
|
RTS
|
|
*
|
|
:RET DS 2
|
|
:RIGHT DS 1
|
|
:LEFT DS 1
|
|
:LENGTH DS 1
|
|
*
|
|
*``````````````````````````````*
|
|
* __P: PRINT FOLLOWING ASC *
|
|
*- -*
|
|
* THIS IS THE XPRINT ROUTINE *
|
|
* FROM STDIO.LIB, BUT STRIPPED *
|
|
* OF COMMENTS. FOR DEBUG. *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__P
|
|
PLA
|
|
STA ADDR1
|
|
PLA
|
|
STA ADDR1+1
|
|
LDY #1
|
|
:LP LDA (ADDR1),Y
|
|
BEQ :DONE
|
|
JSR $FDF0
|
|
INY
|
|
BNE :LP
|
|
:DONE CLC
|
|
TYA
|
|
ADC ADDR1
|
|
STA ADDR1
|
|
LDA ADDR1+1
|
|
ADC #0
|
|
PHA
|
|
LDA ADDR1
|
|
PHA
|
|
RTS
|
|
*
|
|
*``````````````````````````````*
|
|
* __W: WAIT FOR KEYPRESS *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__W
|
|
JSR $FD0C
|
|
RTS
|
|
*
|
|
*``````````````````````````````*
|
|
* __RDMP: REGISTRY DUMP *
|
|
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
|
|
*
|
|
__RDMP
|
|
STA :A
|
|
STX :X
|
|
STY :Y
|
|
:C BCC :C0
|
|
BCS :C1
|
|
:Z BEQ :Z1
|
|
BNE :Z0
|
|
:N BMI :N1
|
|
BPL :N0
|
|
:O BVC :O0
|
|
BVS :O1
|
|
JMP :RDUMP
|
|
:C0 LDA #0
|
|
STA :CARRY
|
|
JMP :Z
|
|
:C1 LDA #1
|
|
STA :CARRY
|
|
JMP :Z
|
|
:Z1 LDA #1
|
|
STA :ZERO
|
|
JMP :N
|
|
:Z0 LDA #0
|
|
STA :ZERO
|
|
JMP :N
|
|
:N1 LDA #1
|
|
STA :NEGATIVE
|
|
JMP :O
|
|
:N0 LDA #0
|
|
STA :NEGATIVE
|
|
JMP :O
|
|
:O0 LDA #0
|
|
STA :OVERFLOW
|
|
JMP :RDUMP
|
|
:O1 LDA #1
|
|
STA :OVERFLOW
|
|
*
|
|
:RDUMP
|
|
_PRNT " ",8D8D
|
|
_PRNT "REGISTRY DUMP",8D
|
|
_PRNT "=============",8D
|
|
_PRNT "A: "
|
|
LDA :A
|
|
AND #$F0 ; MASK RIGHT
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
STA :LEFT
|
|
LDA :A
|
|
AND #$0F ; MASK LEFT
|
|
STA :RIGHT
|
|
LDX :LEFT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDX :RIGHT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
_PRNT " ",8D
|
|
_PRNT "X: "
|
|
LDA :X
|
|
AND #$F0 ; MASK RIGHT
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
STA :LEFT
|
|
LDA :X
|
|
AND #$0F ; MASK LEFT
|
|
STA :RIGHT
|
|
LDX :LEFT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDX :RIGHT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
_PRNT " ",8D
|
|
_PRNT "Y: "
|
|
LDA :Y
|
|
AND #$F0 ; MASK RIGHT
|
|
LSR
|
|
LSR
|
|
LSR
|
|
LSR
|
|
STA :LEFT
|
|
LDA :Y
|
|
AND #$0F ; MASK LEFT
|
|
STA :RIGHT
|
|
LDX :LEFT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
LDX :RIGHT
|
|
LDA HEXTAB,X
|
|
JSR $FDF0
|
|
_PRNT " ",8D8D
|
|
_PRNT "STATUS FLAGS",8D
|
|
_PRNT "============",8D8D
|
|
LDA #0
|
|
CMP :CARRY
|
|
BEQ :CARCLR
|
|
_PRNT "CARRY: SET",8D
|
|
JMP :TESTN
|
|
:CARCLR _PRNT "CARRY: CLEAR",8D
|
|
:TESTN LDA #0
|
|
CMP :NEGATIVE
|
|
BEQ :NEGCLR
|
|
_PRNT "NEGATIVE: SET",8D
|
|
JMP :TESTZ
|
|
:NEGCLR _PRNT "NEGATIVE: CLEAR",8D
|
|
:TESTZ LDA #0
|
|
CMP :ZERO
|
|
BEQ :ZCLR
|
|
_PRNT "ZERO: SET",8D
|
|
JMP :TESTO
|
|
:ZCLR _PRNT "ZERO: CLEAR",8D
|
|
:TESTO
|
|
LDA #0
|
|
CMP :OVERFLOW
|
|
BEQ :OCLR
|
|
_PRNT "OVERFLOW: SET",8D
|
|
JMP :FIN
|
|
:OCLR _PRNT "OVERFLOW: CLEAR",8D8D8D
|
|
:FIN
|
|
RTS
|
|
*
|
|
** DATA
|
|
*
|
|
:A DS 1
|
|
:X DS 1
|
|
:Y DS 1
|
|
:LEFT DS 1
|
|
:RIGHT DS 1
|
|
:OVERFLOW DS 1
|
|
:NEGATIVE DS 1
|
|
:CARRY DS 1
|
|
:ZERO DS 1
|
|
HEXTAB ASC "0123456789ABCDEF"
|
|
*
|
|
*
|
|
********************************
|
|
* *
|
|
* GLOBAL VARIABLES *
|
|
* *
|
|
********************************
|
|
*
|
|
** 256 BYTES DEDICATED TO RETURN
|
|
** VALUES OF VARIABLE LENGTH; CAN BE
|
|
** MODIFIED TO SUIT SMALLER OR LARGER
|
|
** NEEDS.
|
|
*
|
|
*
|
|
RETLEN DS 1 ; RETURN VALUE BYTE LENGTH
|
|
RETURN DS 256
|
|
*
|
|
** 256 BYTE VALUE DEDICATED TO LARGE
|
|
** OR VARIABLE LENGTH PARAMETERS. THIS
|
|
** CAN ALSO BE CHANGED TO FIT SMALLER OR
|
|
** LARGER BOUNDS.
|
|
*
|
|
PARLEN DS 1
|
|
PARAM DS 256
|
|
*
|