code cleaning

This commit is contained in:
Antoine Vignau 2023-08-21 15:18:59 +02:00
parent 78fab679f2
commit c5cab0bac6
5 changed files with 4829 additions and 5215 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1331,7 +1331,7 @@ surligner_mot
*-----------------------
* PRINT - OK
*-----------------------
* print(texte$,colonne&,ligne&,mode)
* print(couleur$,texte$,colonne&,ligne&,mode)
* 1,s w return address
* 3,s w mode
* 5,s w Y
@ -1450,21 +1450,118 @@ print5 lda printMODE ; do we use links?
print6 brl printLOOP
*-----------------------
* PRINTC - OK
*-----------------------
* printc(texte$,colonne&,ligne&)
* 1,s w return address
* 3,s w Y
* 5,s w X
* 7,s l text pointer
max_colonnes2 = 80 ; 80 - 75
*---
printc lda 9,s
sta dpFROM+2
lda 7,s
sta dpFROM
lda 5,s
sta printX
lda 3,s
sta printY
printcLOOP lda [dpFROM]
and #$ff
bne printc1
printcEXIT lda 1,s
plx
plx
plx
plx
sta 1,s
rts
* 1- print char
printc1 cmp #instrSPACE ; skip space char
beq printc2
cmp #texteSPACE
beq printc2
cmp #texteRC
beq printc3
tax
lda tblATARI,x
and #$ff
pha
lda printX
asl
tax
lda x_coord2,x
pha
lda printY
asl
tay
lda y_coord,y
pha
_MoveTo
_DrawChar
* 4- next character
printc2 inc printX
lda printX
cmp #max_colonnes2
bcc printc4
printc3 lda 7,s ; reset X-coord
sta printX
inc printY
lda printY
cmp #max_lignes
bcc printc4
brl printcEXIT ; out of SHR screen, we exit
* 6- we loop
printc4 inc dpFROM
bne printc5
inc dpFROM+2
printc5 brl printcLOOP
*-----------------------
* DATA FOR PRINT
*-----------------------
printMODE ds 2
printX ds 2
printY ds 2
*---
x_coord = *
x_coord = * ; For game texts
]x = marge_gauche*largeur_caractere ; Premi<6D>re ligne
lup max_colonnes
dw ]x
]x = ]x+largeur_caractere
--^
x_coord2 = * ; For centered texts
]x = 0
lup max_colonnes2
dw ]x
]x = ]x+largeur_caractere
--^
y_coord = *
]y = 0 ; Premi<6D>re ligne
lup max_lignes
@ -1549,16 +1646,14 @@ tblUPPER hex 000102030405060708090A0B0C0D0E0F
*-----------------------
* CPRINT - OK
*-----------------------
* cprint(texte$,ligne&,mode)
* cprint(texte$,ligne&)
* A= ptr to string
* Y= line index
cprint PushLong #0 ; no link pointer
pea ^cprint ; ptr to text
cprint pea ^cprint ; ptr to text
pha
pha ; X
phy ; Y
PushWord #linksOFF ; mode
pea $0000 ; count nb of chars in the string
sta dpFROM
@ -1587,8 +1682,8 @@ cprint1 rep #$20 ; nb chars x 8 to get width
lsr ; /4
lsr ; /8
lsr ; /16
sta 5,s ; fill X from above
jsr print
sta 3,s ; fill X from above
jsr printc ; the new centered print routine
rts ; must be RTS
*-----------------------
@ -2144,261 +2239,7 @@ musique
fin_musique
rts
*-----------------------
* TEXT ROUTINES
*-----------------------
*-----------------------
* add_char
*-----------------------
* 5,s char to add
* 3,s pointer to string
* 1,s RTS
add_char
lda 3,s
sta dpTO
sep #$30 ; 02 AB
lda (dpTO) ; cannot exceed 255 chars
cmp #$ff
bcs add_char1
inc ; 03 AB
sta (dpTO) ; 03
tay
lda 5,s ; C
sta (dpTO),y ; 03 ABC
add_char1
rep #$30
lda 1,s ; rŽcup<75>re RTS
plx ; dŽpile les param<61>tres
plx
sta 1,s ; remet le RTS
rts
*-----------------------
* copy_string
*-----------------------
* 7,s number of chars to copy
* 5,s pointer to source string
* 3,s pointer to destination string
* 1,s RTS
copy_string
lda 5,s
sta dpFROM
lda 3,s
sta dpTO
sep #$20
ldy #0
]lp lda (dpFROM),y ; recopie les caract<63>res
sta (dpTO),y
iny
tya
cmp 7,s
bcc ]lp
* beq ]lp
rep #$20
lda 1,s ; rŽcup<75>re RTS
plx ; dŽpile les param<61>tres
plx
plx
sta 1,s ; remet le RTS
rts
*-----------------------
* charcmp
*-----------------------
* 5,s char to compare
* 3,s pointer to string
* 1,s RTS
charcmp
lda 3,s
sta dpFROM
ldx #FALSE ; default value, les chanes sont diffŽrentes
sep #$20
lda (dpFROM)
cmp 5,s ; compare strings
bne charcmp1
ldx #TRUE ; m<EFBFBD>me chane
charcmp1
rep #$20
lda 1,s ; rŽcup<75>re RTS
ply ; dŽpile les param<61>tres
ply
sta 1,s ; remet le RTS
txa ; return value
cmp #TRUE ; met les valeurs de comparaison
rts
*-----------------------
* left
*-----------------------
* 7,s number of chars to copy
* 5,s pointer to source string
* 3,s pointer to destination string
* 1,s RTS
left
lda 5,s
sta dpFROM
lda 3,s
sta dpTO
* check added length
sep #$30 ; check length
ldy #0
]lp lda (dpFROM),y ; recopie les caract<63>res
sta (dpTO),y
iny
tya
cmp 7,s
bcc ]lp
* beq ]lp
rep #$30
lda 1,s ; rŽcup<75>re RTS
plx ; dŽpile les param<61>tres
plx
plx
sta 1,s ; remet le RTS
rts
*-----------------------
* val
*-----------------------
* 5,s string length
* 3,s pointer to source string
* 1,s RTS
* on return, A = unsigned value
val
lda 3,s
sta dpFROM
sep #$20
ldy #0
tyx
]lp lda (dpFROM),y ; recopie les caract<63>res
cmp #' ' ; skip space char
beq val1
sta val_temp,x ; save
inx
val1 iny
tya
cmp 5,s
bcc ]lp
* beq ]lp
cpx #0 ; exit if len is still 0
beq val2
rep #$20
PushWord #0 ; wordspace
PushLong #val_temp ; strPtr
phx ; strLength
pea $0000 ; signedFlag
_Dec2Int
plx ; intResult
val2
rep #$20
lda 1,s ; rŽcup<75>re RTS
ply ; dŽpile les param<61>tres
ply
sta 1,s ; remet le RTS
txa ; return value
rts
val_temp ds 8 ; longueur de la cha”ne temporaire
*-----------------------
* instr
*-----------------------
* 7,s length of string to search
* 5,s pointer to character to find
* 3,s pointer to source string
* 1,s RTS
instr
lda 3,s
sta dpFROM
sep #$20
ldy #0 ; AB
]lp lda (dpFROM),y
iny
cmp 5,s
beq instr2 ; on a trouvŽ le caract<63>re
tya
cmp 7,s
bcc ]lp
* beq ]lp
instr1
ldy #-1 ; on n'a pas trouvŽ le caract<63>re
instr2
rep #$20
lda 1,s ; rŽcup<75>re RTS
plx ; dŽpile les param<61>tres
plx
plx
sta 1,s ; remet le RTS
tya ; return value
rts
*-----------------------
* strcmp
*-----------------------
* 7,s length to compare
* 5,s pointer to string 2
* 3,s pointer to string 1
* 1,s RTS
strcmp
lda 3,s
sta dpFROM
lda 5,s
sta dpTO
ldx #FALSE ; default value, les chanes sont diffŽrentes
sep #$30
ldy #0 ; AB
]lp lda (dpFROM),y
cmp (dpTO),y
bne strcmp2
iny
tya
cmp 7,s
bcc ]lp
* beq ]lp
strcmp1
ldx #TRUE ; m<EFBFBD>me chane
strcmp2
rep #$30
lda 1,s ; rŽcup<75>re RTS
ply ; dŽpile les param<61>tres
ply
ply
sta 1,s ; remet le RTS
txa ; return value
cmp #TRUE ; met les valeurs de comparaison
rts
* IT'S THE END - Antoine
*-----------------------

View File

@ -40,46 +40,6 @@
jsr cprint
eom
*@print mac
* lda #]1
* ldx #]2
* ldy #]3
* jsr print
* eom
@val mac
PushWord ]2
PushWord ]1
jsr val
eom
@left mac
PushWord ]3
PushWord ]2
PushWord ]1
jsr left
eom
@charcmp mac
PushWord #]2
PushWord #]1
jsr charcmp
eom
@copystring mac
PushWord #]3
PushWord #]2
PushWord #]1
jsr copy_string
eom
@instr mac
PushWord #]3
PushWord #]2
PushWord #]1
jsr instr
eom
*----------------------------------- Constantes
*-------------- Softswitches
@ -325,8 +285,9 @@ taskLOOP inc VBLCounter0
* PushWord #%11111111_11111111
* PushLong #taskREC
* _TaskMaster
PushWord #0
PushWord #%00000000_00001110
pha
PushWord #%00000000_00001110 ; mouse + keyboard
PushLong #taskREC
_GetNextEvent
pla
@ -345,27 +306,6 @@ taskLOOP inc VBLCounter0
beq mainLOOP ; ...grand saut
bne taskLOOP ; ...sinon on attend
*---------- DEBUG
DEBUG
lda #' '
sta theSTRING
sta theSTRING+2
PushWord scene_actuelle
PushLong #theSTRING
PushWord #4
_Int2Hex
PushWord #150
PushWord #150
_MoveTo
PushLong #theSTRING
_DrawCString
rts
theSTRING asc ' '00
*----------------------------------- Gestion du keyDown
* on gère les open-apple-qqch
@ -753,8 +693,8 @@ waitKEY ldal KBD-1
waitEVENT inc VBLCounter0
PushWord #0 ; wait for a mouse-up event
PushWord #4
pha
PushWord #%00000000_00001110 ; mouse + keyboard
PushLong #taskREC
_GetNextEvent
pla

Binary file not shown.