Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Grammer
- ;00002DA8
- ;01
- ;0104
- ;01
- ;01
- ;I was bored...
- ;=====================:
- ; . . . . :
- ; . . :
- ; . . :
- ; . __ . :
- ; . / \ . :
- ; .(o) ) |. :
- ; . ) / . :
- ; . . .- . :
- ; , | / :
- ; --/ / . :
- ; \ / . :
- ; .___-- . :
- ; \ . :
- ;=====================:
- ;Project.........Grammer
- ;Program.........GRAMMER
- ;Author..........Zeda Elnara (ThunderBolt)
- ;E-mail..........xedaelnara@gmail.com
- ;Size............
- ;Language........English
- ;Programming.....Assembly
- ;Version.........
- ;Last Update.....09:40 15/09/2011
- .binarymode ti8xapp ; TI-83+ Application
- .deflong bjump(label) ; Jump macro
- call BRT_JUMP0
- .dw label
- .enddeflong
- .deflong bcall(label) ; Call macro
- rst rBR_CALL
- .dw label
- .enddeflong
- .variablename "Grammer "
- .defpage 0, 16*1024, $4000 ; Page 0 definition
- .page 0
- .block 128
- .nolist
- #define TASM
- #define bcall(xxxx) rst 28h \ .dw xxxx
- #define equ .equ
- #define ProgStart $4080
- #define LCDDelay() .db $DB,$10,$87,$38,$FB
- .include "Grammer.inc"
- #define Coord(yy,xx) .db 01,yy,xx
- .list
- jp CopyToRAM
- jumptable:
- jp ProgramAccessStart
- call CompatCall
- jp SelectedProg
- jp CompatCall
- jp ProgNameIsInOP1
- EndOfEntries:
- ; bcall(5041h)
- call SetUpData
- call StartMenu
- call GetKey \ or a
- jr nz,$-4
- bcall(4027h)
- StartMenu:
- ; jr $
- ld bc,0
- ld (TempWord3),a
- ld (TempWord4),bc
- ld (TempWord5),hl
- ;======
- call FindGVarData
- ld a,b \ or a
- jr nz,GramVarArc
- ld hl,9BAEh
- inc de \ inc de \ inc de \ inc de
- ex de,hl \ in a,(6)
- cp (hl) \ ex de,hl
- jr z,GramVarArc
- ld bc,3 \ lddr
- GramVarArc:
- ;======
- in a,(6)
- ld hl,GrammerHook
- bcall(5026h)
- ;======
- ld hl,ZeroProg
- rst 20h
- ld hl,86ECh
- ld (DrawBufPtr),hl
- xor a \ ld (8479h+22),a
- ld a,3
- SelectProgLoop:
- push af
- call ClrDrawToken+4
- ld hl,ChooseProgText
- call GPutS
- pop af
- cp 3
- jr nz,$+12
- bcall(_FindAlphaUp) \ jr c,NoMoreProgs \ call IsOP1GrammerProg
- jr nz,$-8
- cp 2
- jr nz,$+12
- bcall(_FindAlphaDn) \ jr c,NoMoreProgs \ call IsOP1GrammerProg
- jr nz,$-8
- ld hl,8478h
- ld de,8478h+44
- ld bc,9 \ ldir
- NoMoreProgs:
- Coord(6,3)
- ld hl,8479h+44
- call GPutSS
- call GraphToLCD
- call GetKey \ or a
- jr nz,$-4
- call GetKey \ or a
- jr z,$-4
- cp 11
- jr nz,$+6
- set 2,(iy+33)
- cp 10
- jr nz,$+6
- res 2,(iy+33)
- cp 15 \ ret z
- cp 9
- jr nz,SelectProgLoop
- SelectedProg:
- ld hl,9340h
- ld (DrawBufPtr),hl
- ; jr $
- ld de,8478h
- ld hl,8478h+44
- ld bc,9 \ ldir
- ld a,(TempWord3)
- or a \ jr z,ExecProgNow
- ld hl,GramTempName
- rst 20h
- ld hl,(TempWord4)
- ld a,h \ or l
- ret z
- ld a,16h
- bcall(4E70h)
- inc de \ inc de
- ld a,(TempWord3)
- ld bc,(TempWord4)
- ld hl,(TempWord5)
- call ReadArc
- ld hl,8478h+33
- rst 20h
- ExecProgNow:
- ; pop de \ pop af
- ; or a
- ; jr z,ProgramAccessStart-3
- ; ld hl,9BAEh ;ParserHookPtr
- ; ld bc,3
- ; inc de \ inc de
- ; ld a,(de) \ cp (hl)
- ; jr z,ProgramAccessStart-3
- ; lddr
- jp ProgNameisInOP1
- ProgramAccessStart:
- ; call SetUpData
- bcall(_RclAns) ;EFD74A
- sub 4 ;D604 Check if string...
- jr z,$+15 ;280D
- ld bc,6 ;010600
- ld hl,965Bh ;215B96
- ld de,progStart ;11****
- ldir ;EDB0
- jr grazh ;18**
- ex de,hl ;EB
- ld c,(hl) ;4E
- inc hl ;23
- ld b,(hl) ;46
- inc hl ;23
- ld de,8478h ;117884
- ldir ;EDB0
- ld (de),a ;12
- PrognameIsInOP1:
- ld hl,8478h
- ld de,9652h
- ld bc,9 \ ldir
- bcall(_ChkFindSym) ;EFF142
- ld a,b
- ret c ;D8
- or a \ ret nz
- ex de,hl ;EB
- ld c,(hl) ;4E
- inc hl ;23
- ld b,(hl) ;46
- inc hl ;23
- ld (965Bh),hl
- ld (progPtr),hl ;227298
- ld (progStart),hl ;227698
- ld h,a \ ld l,a
- ld (parseError),hl
- ; add hl,bc ;09
- ; ld (progEnd),hl ;227498
- ; dec hl ;2B
- ; ld a,(hl) ;7E
- ; cp $D9 ;FED9 Stop token
- ; ret nz ;C0
- grazh:
- call SetUpData
- ld hl,BreakProgram
- push hl
- ParserNext:
- bit 2,(iy+34)
- call z,CheckStatus
- call z,ONErr
- ld de,ParserNext ;11****
- push de ;D5
- ParseArg:
- ld hl,(progPtr) ;2A7298
- ; call IsHLAtEOF ;CD****
- ; jr c,NotEOF ;3002
- ; pop hl ;E1
- ; ret ;C9
- bit 1,(iy+33)
- jr nz,$+3
- ei
- NotEOF:
- ld a,(hl) ;7E
- inc hl ;23
- ld (progPtr),hl ;227298
- cp 3Fh
- jr nz,$+6
- ld (Ans),bc
- call EndOArgNotSto ;
- ret z
- ThenToken:
- cp $CF \ jr z,ParserNext
- OutputToken:
- cp $E0 \ jr nz,augment
- ld a,(hl)
- cp 11
- jr nz,$+10
- call ParseNextFullArg
- ld a,c
- ld (OutputLogic),a
- ret
- call ParseFullArg
- dec c
- ld bc,vFont
- set 5,(iy+34)
- ld a,(hl)
- jr z,$+9
- res 5,(iy+34)
- ld bc,FontSet
- cp 2Bh \ call z,ParseNextFullArg
- ld (FontPointer),bc
- ret
- augment:
- cp 20 \ jr nz,PtChange
- call ParseFullArg
- ld h,b \ ld l,c
- bcall(42FDh)
- jp c,ErrMem
- push de
- call ParseNextFullArg
- push bc
- ld hl,(progPtr)
- inc hl
- ld (progPtr),hl
- call GetVarInfo
- jp c,Pop2Exit
- or a \ jp nz,Pop2Exit
- ld hl,(progPtr)
- ld (965Dh),hl
- ex de,hl
- ld c,(hl) \ inc hl
- ld b,(hl)
- ld (TempWord1),hl
- pop de \ pop hl
- push hl
- add hl,bc
- ld b,h \ ld c,l
- ld hl,(TempWord1)
- ld (hl),b \ dec hl
- ld (hl),c \ inc hl \ inc hl
- add hl,de
- pop de
- ;hl points to where to insert data
- ;de is the number of bytes to insert
- push de \ push hl
- ld a,h \ or l
- jr z,$+6
- ex de,hl
- bcall(42F7h)
- ld hl,(965Dh)
- ld (progPtr),hl
- pop hl \ pop bc
- push hl
- jp ZeroMem
- PtChange:
- cp 160 \ jp nz,solveSet
- call ParseFullArg ;To get the tilemap routine correct
- call ParseNextFullArg ;Map Data
- push bc
- call ParseNextFullArg ;Tile Data
- push bc
- call ParseNextFullArg ;MapWidth
- push bc
- call ParseNextFullArg ;MapX offset
- ld (TempWord2),bc
- call ParseNextFullArg ;MapY offset
- ld (TempWord3),bc
- call ParseNextFullArg ;Sprite Method
- ld a,c
- pop hl
- pop bc
- pop de
- jp TileMap1
- solveSet:
- cp 22h \ jp nz,ISToken
- ld a,(hl) \ inc hl \ ld (progPtr),hl
- sub 30h \ ld b,a
- jr nz,CopyDataUp
- inc hl \ ld (progPtr),hl
- call GetVarInfo2 \ ret c
- push af \ push hl \ push bc
- ld hl,(progPtr)
- inc hl \ ld (progPtr),hl
- call GetVarInfo
- jr c,$+5
- bcall(4FC6h)
- pop hl \ push hl
- ld a,(8478h)
- and 1fh
- bcall(4E70h)
- inc de \ inc de
- pop bc \ pop hl \ pop af
- push de \ push bc
- call TSA
- pop hl \ ld (ThetaPrimeVar),hl
- pop bc \ ret
- CopyDataUp:
- djnz CopyDataDown
- push bc
- call ParseNextFullArg
- push bc
- call ParseNextFullArg
- push bc
- call ParseNextFullArg
- pop de \ pop hl
- ldir
- pop bc
- ret
- CopyDataDown:
- djnz ErrorHandle
- push bc
- call ParseNextFullArg
- push bc
- call ParseNextFullArg
- push bc
- call ParseNextFullArg
- pop de \ pop hl
- lddr
- pop bc
- ret
- ErrorHandle:
- djnz CallError
- call ParseNextFullArg
- ld (ParseError),bc
- ret
- CallError:
- djnz Getname
- call ParseNextFullArg
- ld a,c
- cp 2
- jr nz,HandleError
- call ParseNextFullArg
- ld h,b \ ld l,c
- call GetGrammerText
- ld hl,13 \ or a
- sbc hl,bc
- jr nc,$+5
- ld bc,13
- ex de,hl
- ld de,984Dh
- ldir
- xor a
- ld (de),a
- ld a,2
- HandleError:
- jp GramHandl
- GetName:
- ; djnz GetLine
- GetLine:
- ret
- ISToken:
- cp $DA \ jr nz,AnsToken
- ld a,(hl) \ inc hl
- call VarPointer
- ret nc \ dec de
- ld (progPtr),de
- ld e,(hl) \ inc (hl) \ inc hl \ ld d,(hl)
- jr nz,$+3
- inc (hl)
- ex de,hl
- ld c,(hl)
- ld b,0
- ret
- AnsToken:
- cp 72h \ jr nz,InputTOken
- ld bc,(Ans) \ ret
- InputToken:
- cp $DC \ jp nz,SeqToken
- ld hl,(textRow)
- ld (TempWord2),hl
- set 3,(iy+33)
- ClearP:
- ld hl,(TempWord2)
- ld (textRow),hl
- ld hl,8508h
- ld (hl),3Eh \ inc hl
- ld (hl),3Fh
- ld (TempWord1),hl
- InputLoop:
- res 4,(iy+9)
- bcall(500Bh)
- ; jr $
- cp 5 \ jr z,EnterP
- cp 9 \ jr z,ClearP
- cp 10 \ jr z,DelP
- bcall(4A02h)
- ld hl,(TempWord1)
- ld bc,8587h \ or a
- sbc hl,bc \ add hl,bc
- jr nc,InputLoop
- ld a,d \ or a
- jr z,$+4
- ld (hl),d \ inc hl
- ld (hl),e \ inc hl
- ld (TempWord1),hl
- ld (hl),3Fh
- jr DispInputString
- DelP:
- ld hl,(TempWord1)
- ld de,850Ah
- ; jr $
- or a \ sbc hl,de
- add hl,de
- jr c,DelDone
- dec hl \ dec hl
- ld a,(hl) \ call Is_2_Byte
- jr z,$+3
- inc hl
- ld (TempWord1),hl
- DelDone:
- ld (hl),3Fh
- DispInputString:
- ld hl,8508h
- call GetGrammerText
- ld hl,(TempWord2)
- ld (TextRow),hl
- ex de,hl
- call PutSM
- ld a,20h
- call PutSC
- ;DE points to string
- ;BC is the size
- call GraphToLCD
- jr InputLoop
- EnterP:
- ld bc,8509h
- res 3,(iy+33)
- ret
- seqToken:
- ; cp 35 \ jr nz,SetData
- SetData:
- cp 6 \ jr nz,VarName
- dec hl
- ld (progPtr),hl
- ld h,b \ ld l,c
- SetDataLoop:
- push hl
- call ParseNextFullArg
- ld a,(hl) \ pop hl
- ld (hl),c \ inc hl
- cp 2Bh \ ret nz
- jr SetDataLoop
- VarName:
- ld e,a
- add a,82h
- call Is_Var_Name
- ld a,e
- jr nz,FuncToken
- ld d,(hl) \ inc hl
- ld (progPtr),hl
- ld (8479h),de
- xor a \ ld (847Bh),a
- rst 10h
- jp VarTokenStepIn
- FuncToken:
- cp 76h \ jr nz,SendToken
- call ParseFullArg
- ld (8A8Ah+IprogPtr-interrupt),bc
- ret
- SendToken:
- cp $E7 \ jr nz,PToRy
- call ParseFullArg
- push bc ;Size of the var
- inc hl \ ld (progPtr),hl
- call GetVarName
- ex de,hl
- ld de,8478h
- ldir
- xor a
- ld (de),a
- bcall(_ChkFindSym)
- pop hl
- jr nc,PToRy-5
- VarDoesNotExistYet:
- ld a,(8478h)
- and 1fh
- push hl
- bcall(4E70h)
- pop bc
- ld h,d \ ld l,e \ inc hl \ inc hl
- xor a
- call SetMem
- inc de \ inc de
- ld c,e \ ld b,d
- ret
- PToRy:
- cp 30 \ jr nz,RToPR
- call ParseFullArg
- ld a,c \ ld (8A13h),a
- ld a,(hl) \ cp 2Bh
- call ParseNextFullArg
- ret
- RToPr:
- cp 27 \ jr nz,RToPTheta
- ld hl,(PBufPtr)
- inc hl \ inc hl
- ld (hl),0 \ inc hl
- ld (hl),0 \ inc hl
- ret
- RToPTheta:
- cp 28 \ jp nz,PToRX
- ld a,(hl)
- call EndOArg
- jr z,DefaultBuffer
- call ParseFullArg
- ld (PBufPtr),bc
- DefaultBuffer:
- ld hl,(PBufPtr) \ inc hl \ inc hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- push bc
- StartPLoop:
- ld a,b \ or c
- jr nz,ContPLoop
- pop bc \ ret
- ContPLoop:
- push bc
- push hl
- ParticleType:
- ld a,(8A13h) \ or a
- jr nz,PartType1
- call RemoveParticle
- call ParticlePixelD_LR
- jr z,EndPLoop
- jr EndParticle
- PartType1:
- dec a \ jr nz,PartType2
- call RemoveParticle
- call ParticlePixelD_LR
- jr z,EndPLoop
- dec c
- push bc
- call GetPixelLoc
- pop bc
- and (hl)
- jr z,EndPLoop
- jr EndParticle
- PartType2:
- dec a \ jr nz,PartType3
- call RemoveParticle
- call ParticlePixelD_LR
- jr z,EndPLoop
- push bc
- dec c
- call GetPixelLoc
- pop bc
- and (hl)
- jr z,EndPLoop
- set 7,b \ set 7,c
- jr EndPLoop
- PartType3:
- dec a \ jr nz,PartType4
- pop hl
- ld c,(hl) \ inc hl
- ld b,0
- push bc \ push hl
- call RemoveParticle
- pop hl \ ld d,h \ ld e,l
- pop bc \ push bc
- inc hl \ inc hl \ ldir
- pop bc \ push bc \ ldir
- push hl
- call ParticlePixelD_LR
- jr z,EndWorm
- push bc
- dec c
- call GetPixelLoc
- pop bc
- and (hl)
- jr z,EndWorm
- set 7,b \ set 7,c
- EndWorm:
- pop hl
- ld (hl),c \ inc hl
- ld (hl),b \ inc hl
- push hl
- call GetPixelLoc
- jr nc,$+4 ;Dont draw
- or (hl) \ ld (hl),a
- pop de
- pop bc
- pop hl \ scf
- dec hl \ dec hl
- sbc hl,bc \ sbc hl,bc
- ld b,h \ ld c,l
- ex de,hl
- jp StartPloop
- ;hl points to next worm
- ;de points to last worm pixel
- ;bc fucked
- ;04 02020303040405050505
- PartType4:
- EndParticle:
- ld b,d \ ld c,e
- EndPLoop:
- pop hl
- ld (hl),c \ inc hl
- ld (hl),b
- push hl
- call GetPixelLoc
- jr c,DoneRemoving
- pop hl
- pop bc
- dec bc
- ld d,h \ ld e,l
- add hl,bc \ add hl,bc
- ldd \ ld a,(hl) \ ld (de),a
- inc bc
- push de
- ld hl,(PBufPtr) \ inc hl \ inc hl
- ld e,(hl) \ inc hl
- ld d,(hl) \ dec de
- ld (hl),d \ dec hl
- ld (hl),e
- pop hl
- ;
- jp StartPloop
- DoneRemoving:
- or (hl) \ ld (hl),a
- pop hl
- inc hl
- pop bc
- dec bc
- jp StartPloop
- PToRX:
- cp 29 \ jp nz,FixToken
- ld hl,(PBufPtr)
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ld e,(hl) \ inc hl
- ld d,(hl) \ inc hl
- ld a,(8A13h) \ cp 3
- jr nz,NotWorm
- push hl
- ld h,b \ ld l,c
- or a
- sbc hl,de
- jr nz,$+4
- pop hl \ ret
- push hl \ push de
- jr wormStepIn
- NotWorm:
- sra b \ rr c \ dec bc
- ;BC=Max number of particles
- ;DE=Current number of particles
- ;HL=particle pointer
- ex de,hl
- sbc hl,bc \ ret z
- add hl,bc
- inc hl
- ex de,hl
- push hl
- dec hl \ ld (hl),d
- dec hl \ ld (hl),e
- ex de,hl
- add hl,hl
- add hl,de
- ;HL points to where particle data gets written
- push hl
- wormStepIn:
- call ParseFullArg
- push bc
- call ParseNextFullArg ;CD****
- ld a,c
- pop bc \ ld b,a
- ld a,(8A13h)
- cp 3 \ jr z,AddWorm
- pop hl
- ld (hl),c \ inc hl
- ld (hl),b
- call GetPixelLoc
- or (hl) \ ld (hl),a
- pop bc
- ret
- AddWorm:
- ;{PartLocation,Sizeleft,CurrentBufSize
- push bc \ call ParseNextFullArg
- ld l,c \ pop bc
- ld (TempWord1),bc
- pop bc ;CurrentSize
- pop de ;SizeLeft
- ld h,0 \ add hl,hl \ inc l ; size requested
- ex de,hl \ or a \ sbc hl,de
- jr nc,SizeGood
- ex de,hl \ sbc hl,de \ ex de,hl
- SizeGood:
- ld h,b \ ld l,c
- add hl,de
- ld b,h \ ld l,c
- pop hl
- dec hl \ ld b,(hl)
- dec hl \ ld c,(hl)
- add hl,bc \ inc hl \ inc hl
- dec de \ sra d \ rr e
- ret z
- dec e \ ret z
- ld (hl),e
- inc e
- ld bc,(TempWord1)
- WritewormDat:
- inc hl \ ld c,(hl)
- inc hl \ ld b,(hl)
- dec e
- jr z,WritewormDat
- call GetPixelLoc
- or (hl) \ ld (hl),a
- ld bc,0
- ret
- ;{PartLocation
- ;hl is particle location
- ;de is size requested
- ;bc current size
- FixToken:
- cp 73h
- jr nz,OSVarToken
- ld a,(hl)
- cp 93h
- jr nz,SetMode
- call ParseNextFullArg
- ld a,c
- ld (TextPauseTime),a
- ret
- SetMode:
- call ParseFullArg
- ld a,c
- ld (8A12h),a
- ret
- OSVarToken:
- cp 44
- jr nz,TangentToken
- ld a,(hl)
- inc hl
- ld (progPtr),hl
- ld hl,0
- ld (847Ah),hl
- ld (8479h),a
- rst 10h
- jr nc,$+6
- ld bc,0
- ret
- inc de \ ex de,hl
- call ConvDecAtHL
- ld b,d \ ld c,e
- ret
- TangentToken:
- cp $A7
- jp nz,PiToken
- call ParseFullArg ;CD****
- xor a \ ld b,a
- or c
- ret z
- push bc
- call ParseNextFullArg ;CD****
- ld a,c
- pop bc
- or a \ ret z
- ld b,4
- push bc
- rrca
- push af
- ld a,c
- call c,ShiftGraphDownA
- pop af
- pop bc
- push bc
- rrca
- push af
- ld a,c
- call c,ShiftGraphLeftA
- pop af
- pop bc
- push bc
- rrca
- push af
- ld a,c
- call c,ShiftGraphRightA
- pop af
- pop bc
- rrca
- ld a,c
- ret nc
- ShiftGraphUpA:
- ld de,12
- call DE_Times_A
- push hl
- ld a,h
- inc a
- cpl
- and 3
- ld b,a
- ld a,l
- dec a
- cpl
- ld c,a
- ld de,GraphBuf
- add hl,de
- ldir
- pop bc
- ZeroMemF:
- xor a
- SetMemF:
- ld (de),a
- ld h,d \ ld l,e
- inc de
- ldir
- ret
- ShiftGraphRightA:
- rrca
- push af
- call c,ShiftRight1
- pop af
- rrca
- push af
- call c,ShiftRight2
- pop af
- rrca
- push af
- call c,ShiftRight4
- pop af
- rrca
- push af
- call c,ShiftRight8
- pop af
- rrca
- push af
- call c,ShiftRight16
- pop af
- rrca
- push af
- call c,ShiftRight32
- pop af
- rrca
- ret nc
- ShiftRight64:
- ld a,4
- ld l,37h
- jr ShiftRight8OrMore
- ShiftRight32:
- ld a,8
- ld l,3Bh
- jr ShiftRight8OrMore
- ShiftRight16:
- ld a,10
- ld l,3Dh
- ShiftRight8OrMore:
- ld h,96h
- ld (TempWord3),a
- ld b,64
- ld de,GraphBuf+2FFh
- SR8OMLoop:
- push bc
- ld bc,(TempWord3) \ ld b,0
- lddr
- ld b,8
- xor a
- ld (de),a
- dec de
- dec hl
- djnz $-3
- pop bc
- djnz SR8OMLoop
- ret
- ShiftRight8:
- ld hl,GraphBuf
- ld d,64
- xor a
- ld b,12
- ld c,(hl)
- ld (hl),a
- inc hl
- ld a,c
- djnz $-4
- dec d
- jr nz,$-10
- ret
- ShiftRight2:
- call ShiftRight1
- ShiftRight1:
- ld hl,GraphBuf
- ld c,64
- xor a
- ld b,12
- .dw 1ECBh
- inc hl
- djnz $-3
- dec c
- jr nz,$-9
- ret
- ShiftRight4:
- ld hl,GraphBuf
- ld c,64
- xor a
- ld b,12
- .dw 67EDh
- inc hl
- djnz $-3
- dec c
- jr nz,$-9
- ret
- ShiftGraphLeftA:
- rrca
- push af
- call c,ShiftLeft1
- pop af
- rrca
- push af
- call c,ShiftLeft2
- pop af
- rrca
- push af
- call c,ShiftLeft4
- pop af
- rrca
- push af
- call c,ShiftLeft8
- pop af
- rrca
- push af
- call c,ShiftLeft16
- pop af
- rrca
- push af
- call c,ShiftLeft32
- pop af
- rrca
- ret nc
- ShiftLeft64:
- ld a,4
- ld l,48h
- jr ShiftLeft8OrMore
- ShiftLeft32:
- ld a,8
- ld l,44h
- jr ShiftLeft8OrMore
- ShiftLeft16:
- ld a,10
- ld l,42h
- ShiftLeft8OrMore:
- ld h,93h
- ld (TempWord3),a
- ld b,64
- ld de,GraphBuf+2FFh
- SL8OMLoop:
- push bc
- ld bc,(TempWord3) \ ld b,0
- ldir
- ld b,8
- xor a
- ld (de),a
- inc de
- inc hl
- djnz $-3
- pop bc
- djnz SL8OMLoop
- ret
- ShiftLeft8:
- ld hl,GraphBuf+767
- ld d,64
- xor a
- ld b,12
- ld c,(hl)
- ld (hl),a
- dec hl
- ld a,c
- djnz $-4
- dec d
- jr nz,$-10
- ret
- ShiftLeft2:
- call ShiftLeft1
- ShiftLeft1:
- ld hl,GraphBuf+767
- ld c,64
- xor a
- ld b,12
- .dw 16CBh
- dec hl
- djnz $-3
- dec c
- jr nz,$-9
- ret
- ShiftLeft4:
- ld hl,GraphBuf+767
- ld c,64
- xor a
- ld b,12
- .dw 6FEDh
- dec hl
- djnz $-3
- dec c
- jr nz,$-9
- ret
- ShiftGraphDownA:
- ld de,12
- call DE_Times_A
- push hl
- ld a,h
- inc a
- cpl
- and 3
- ld b,a
- ld a,l
- dec a
- cpl
- ld c,a
- ld hl,GraphBuf-1
- add hl,bc
- ld de,GraphBuf+767
- lddr
- pop bc
- ZeroMemE:
- xor a
- SetMemE:
- ld (de),a
- ld h,d \ ld l,e
- dec de
- lddr
- ret
- PiToken:
- cp $AC
- jr nz,nCrToken
- ConvHexStr:
- ex de,hl
- ld hl,0
- ConvHexStrLoop:
- call IsHexTok
- jr c,EndOfPi
- add hl,hl
- add hl,hl
- add hl,hl
- add hl,hl
- or l
- ld l,a
- jr ConvHexStrLoop
- EndOfPi:
- dec de
- ld (progPtr),de
- ld b,h \ ld c,l
- ex de,hl
- ret
- nCrToken:
- cp 95h \ jr nz,ForToken
- push bc
- call ParseFullArg ;CD****
- pop hl
- ld d,b \ ld e,c
- ;===============================================================
- nCrAlgorithm:
- ;===============================================================
- ;Inputs:
- ; hl is "n"
- ; de is "r"
- ;Outputs:
- ; interrupts off
- ; a is 0
- ; bc is the result
- ; de is "n"
- ; hl is the result
- ; a' is not changed
- ; bc' is "r"+1
- ; de' is an intermediate calculation
- ; hl' is "r" or the compliment, whichever is smaller
- ;===============================================================
- or a ;reset carry flag
- sbc hl,de
- ret c ;r should not be bigger than n
- di
- sbc hl,de \ add hl,de
- jr nc,$+3
- ex de,hl ;hl is R
- push de
- ld bc,1 ;A
- exx
- pop de ;N
- ld bc,1 ;C
- ld h,b \ ld l,c ;D
- nCrLoop:
- push de
- push hl
- call DE_Times_BC
- push hl \ exx \ pop de
- push hl
- call DE_Div_BC
- pop de
- push hl \ ex de,hl \ exx \ pop hl
- ld b,h \ ld c,l
- pop de \ add hl,de
- pop de \ inc de
- exx
- inc bc
- or a \ sbc hl,bc \ add hl,bc
- exx
- jr nc,nCrLoop
- ld b,h \ ld c,l
- ret
- ForToken:
- cp $D3 \ jr nz,FullToken
- ld a,(hl)
- inc hl
- call VarPointer
- jp nc,BreakProgram
- ld (progPtr),de
- push hl
- call ParseFullArg ;CD****
- pop hl
- push hl
- ld (hl),c \ inc hl
- ld (hl),b
- call ParseNextFullArg ;CD****
- ld hl,(progPtr)
- ld de,(965Bh) \ or a
- sbc hl,de \ ex de,hl
- pop hl
- StartForLoop:
- push de ;progPtr
- push bc ;UpperBound
- push hl ;varPointer
- call ParserNext
- ld (TempWord1),bc
- pop hl ;points to var data
- pop de ;upper bound
- ld c,(hl)
- inc hl
- ld b,(hl)
- ex de,hl
- ;hl is the upper bound
- ;bc is the current value
- scf
- sbc hl,bc \ add hl,bc
- inc hl
- jr c,ExitForLoop
- inc bc
- ex de,hl
- ld (hl),b
- dec hl
- ld (hl),c
- ld b,d \ ld c,e
- pop de
- push de
- push hl
- ld hl,(965Bh) \ add hl,de
- ex de,hl \ pop hl
- ld (progPtr),de \ pop de
- jr StartForLoop
- ExitForLoop:
- pop de
- ld bc,(TempWord1)
- ret
- FullToken:
- cp 75h
- jr nz,ClrDrawToken
- ld a,(hl)
- ld c,1
- call EndOArg
- call nz,ParseFullArg
- in a,(20h)
- ld b,a
- bit 1,c
- jr z,$+6
- cpl
- and 1
- ld c,a
- in a,(2)
- rlca
- and c
- out (20h),a
- ld c,b
- ld b,0
- ret
- ClrDrawToken:
- cp 85h \ jr nz,ClrHomeToken
- ld hl,0
- ld (textRow),hl
- push bc
- ld bc,768
- ld hl,(BufPtr)
- ZeroMem:
- ld a,b \ or c \ ld a,0
- call nz,SetMem
- pop bc
- ret
- ClrHomeToken:
- cp $E1 \ jr nz,minToken
- ld hl,0
- ld (844Bh),hl
- push bc
- ld bc,128
- ld hl,8508h \ ld a,20h
- jr ZeroMem+1
- minToken:
- cp 1Ah \ jr z,maxToken+4
- maxToken:
- cp 19h \ jr nz,factorialToken
- push af
- call ParseFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- pop hl
- sbc hl,bc
- add hl,bc
- pop de
- bit 0,d
- jr nz,$+3
- ccf
- jr c,$+4
- ld b,h
- ld c,l
- ret
- factorialToken:
- cp 2Dh \ jr nz,FillToken
- ld a,(hl)
- call IsConditional \ jr z,$+9
- ld de,0 \ push de
- jp factorialStepIn
- set 2,(iy+33)
- ret
- FillToken:
- cp $E2 \ jp nz,HorizontalToken
- call ParseFullArg
- ld hl,(BufPtr)
- ld a,c
- ld bc,300h
- ld e,-1
- FillBufOR:
- or a \ jr nz,FillBufInv
- ld a,e \ or (hl) \ ld (hl),a
- cpi
- jp pe,$-5 ;save a byte: ret po
- ret ; jr $-4 ;makes over 5300 cycles slower
- FillBufInv:
- dec a \ jr nz,Checker1
- ld a,e \ xor (hl) \ ld (hl),a
- cpi
- jp pe,$-5
- ret
- Checker1:
- dec a \ jr nz,Checker2
- ld a,$AA
- ld c,64
- ld b,12 \ ld (hl),a \ inc hl
- djnz $-2
- cpl \ dec c
- jr nz,$-8
- ret
- Checker2:
- dec a \ jr nz,LoadBytePatternOR
- ld a,55h \ jr Checker1+5
- LoadBytePatternOR:
- cp 19 \ jr nc,NotArg
- push af \ push bc \ push hl
- call ParseNextFullArg
- ld d,b \ ld e,c \ pop hl \ pop bc \ pop af
- NotArg:
- dec a \ jr z,FillBufOR+3
- LoadBytePatternXOR:
- dec a \ jr z,FillBufInv+3
- LoadBytePatternAND:
- dec a \ jr nz,LoadBytePatternErase
- FillBufAND:
- ld a,e \ and (hl) \ ld (hl),a
- cpi
- jp pe,FillBufAND
- ret
- LoadBytePatternErase:
- dec a \ jr nz,BufCopy
- FillBufErase:
- ld a,e \ cpl \ and (hl) \ ld (hl),a
- cpi
- jp pe,FillBufErase
- ret
- BufCopy:
- dec a \ jr nz,BufOR
- ldir \ ret
- BufOR:
- dec a \ jr nz,BufAND
- ld a,(de) \ inc de
- or (hl) \ ld (hl),a
- cpi \ jp pe,BufOR+3
- ret
- BufAND:
- dec a \ jr nz,BufXOR
- ld a,(de) \ inc de
- and (hl) \ ld (hl),a
- cpi \ jp pe,BufAND+3
- ret
- BufXOR:
- dec a \ jr nz,BufErase
- ld a,(de) \ inc de
- xor (hl) \ ld (hl),a
- cpi \ jp pe,BufXOR+3
- ret
- BufErase:
- dec a \ jr nz,BufSwap
- ld a,(de) \ inc de
- cpl \ and (hl) \ ld (hl),a
- cpi \ jp pe,BufErase+3
- ret
- BufSwap:
- dec a \ jr nz,CopyDown
- ld a,(de)
- push af \ ld a,(hl) \ ld (de),a
- pop af \ ld (hl),a
- inc de
- cpi \ jp pe,BufSwap+3
- ret
- CopyDown:
- ;If Copy Down
- cp 5 \ jr nc,CopyDownOR
- add hl,bc \ dec hl
- push hl
- ld h,d \ ld l,e
- add hl,hl \ add hl,de
- add hl,hl \ add hl,hl
- pop de \ push de \ push hl \ ex de,hl
- sbc hl,de \ ex de,hl
- ld h,b \ ld l,c \ pop bc \ sbc hl,bc
- ld b,h \ ld c,l
- pop hl
- CopyDownOR:
- dec a \ jr nz,CopyDownAND
- ld a,(de)
- or (hl)
- ld (hl),a
- dec de \ cpd
- jp pe,$-6
- ret
- CopyDownAND:
- dec a \ jr nz,CopyDownXOR
- ld a,(de)
- and (hl)
- ld (hl),a
- dec de \ cpd
- jp pe,$-6
- ret
- CopyDownXOR:
- dec a \ jr nz,CopyDownErase
- ld a,(de)
- xor (hl)
- ld (hl),a
- dec de \ cpd
- jp pe,$-6
- ret
- CopyDownErase:
- dec a \ jr nz,CopyUp
- ld a,(de)
- cpl
- and (hl)
- ld (hl),a
- dec de \ cpd
- jp pe,$-7
- ret
- CopyUp:
- ;If Copy Up
- cp 5 \ jr nc,CopyUpOr
- ;de is number of pixels down to copy to
- ;bc is 768
- ;hl points to the buffer
- push hl
- ld h,d \ ld l,e
- add hl,de \ add hl,de
- add hl,hl \ add hl,hl
- ld b,h \ ld c,l
- pop de \ add hl,de
- ;DE points to main buffer
- ;HL points to offset
- push hl
- ld hl,768 \ sbc hl,bc
- ld b,h \ ld c,l
- pop hl
- ex de,hl
- CopyUpOR:
- dec a \ jr nz,CopyUpAND
- ld a,(de)
- or (hl)
- ld (hl),a
- inc de \ cpi
- jp pe,$-6
- ret
- CopyUpAND:
- dec a \ jr nz,CopyUpXOR
- ld a,(de)
- and (hl)
- ld (hl),a
- inc de \ cpi
- jp pe,$-6
- ret
- CopyUpXOR:
- dec a \ jr nz,CopyUpErase
- ld a,(de)
- xor (hl)
- ld (hl),a
- inc de \ cpi
- jp pe,$-6
- ret
- CopyUpErase:
- dec a \ ret nz
- ld a,(de)
- cpl
- and (hl)
- ld (hl),a
- inc de \ cpi
- jp pe,$-7
- ret
- HorizontalToken:
- cp $A6 \ jr nz,VerticalToken
- call ParseFullArg ;CD****
- push bc
- ld d,1
- ld hl,(progPtr)
- ld a,(hl)
- cp 3Fh
- jr z,NoMethodArgA6
- call ParseNextFullArg+3
- ld d,c
- NoMethodArgA6:
- pop hl
- ld b,h
- ld c,l
- add hl,hl \ add hl,bc
- add hl,hl \ add hl,hl
- ld a,h \ sub 3
- ret nc
- ld a,d
- ld bc,(BufPtr)
- add hl,bc
- ld b,12
- or a \ jr z,SetSmallMem
- dec a
- jr nz,InvertMem
- dec a
- SetSmallMem:
- ld (hl),a \ inc hl
- djnz $-2
- ret
- InvertMem:
- ld a,(hl) \ cpl
- ld (hl),a \ inc hl
- djnz $-4
- ret
- VerticalToken:
- cp 9Dh \ jr nz,ShadeToken
- call ParseFullArg ;CD****
- ld a,c \ and 7
- ld b,a \ inc b
- ld a,1
- rrca
- djnz $-1
- srl c \ srl c \ srl c
- ld b,0
- ld hl,(BufPtr) \ add hl,bc
- push af
- push hl
- ld hl,(progPtr)
- ld a,(hl)
- cp 3Fh
- ld a,1
- jr z,NoMethodArg9D
- call ParseNextFullArg+3
- ld a,c
- NoMethodArg9D:
- ;=======================================
- ; A is the method:
- ; 0=Off
- ; 1=On
- ; 2=Invert
- ;=======================================
- pop hl
- pop de
- ld b,a
- ld a,l
- sub 4Ch \ ret c
- ld a,b
- ld bc,400Ch
- DrawVertOn:
- dec a \ jr nz,DrawVertInv
- ld a,d
- or (hl)
- ld (hl),a
- ld a,b \ ld b,0 \ add hl,bc \ ld b,a
- djnz DrawVertOn+3
- ret
- DrawVertInv:
- dec a \ jr nz,DrawVertOff
- ld a,d
- xor (hl)
- ld (hl),a
- ld a,b \ ld b,0 \ add hl,bc \ ld b,a
- djnz DrawVertInv+3
- ret
- DrawVertOff:
- ld a,d
- cpl \ and (hl)
- ld (hl),a
- ld a,b \ ld b,0 \ add hl,bc \ ld b,a
- djnz DrawVertOff
- ret
- ShadeToken:
- cp $A4 \ jr nz,StorePicToken
- call ParseFullArg ;CD****
- ld a,c
- add a,$D9
- jr nc,$+3
- xor a
- dec a
- out (16),a
- ret
- StorePicToken:
- ; cp 98h \ jr nz,RecallPicToken
- ; ret
- RecallPicToken:
- ; cp 99h \ jr nz,RandToken
- ; ret
- RandToken:
- cp $AB
- jr nz,BBTokens
- ld hl,(randSeed)
- inc hl
- ld b,h \ ld c,l
- add hl,hl
- ld hl,(randSeed)
- ld a,r \ ld d,a
- ld a,r \ ld e,a
- add hl,de
- ld a,r \ ld d,a
- ld a,r \ ld e,a
- add hl,de
- ld (randSeed),hl
- ret
- BBTokens:
- cp $BB \ jp nz,CircleToken
- ld a,(hl) ;7E
- inc hl ;23
- ld (progPtr),hl ;227298
- length:
- cp 2Bh \ jr nz,inString
- ld a,(hl)
- cp $AE
- jr nz,FindVarInfo
- call ParseNextFullArg
- push bc
- call ParseNextFullArg
- or a \ sbc hl,hl \ sbc hl,bc
- push hl
- call ParseNextFullArg
- or a \ sbc hl,hl \ sbc hl,bc
- push hl
- ld bc,3Fh
- cp 2Bh \ call z,ParseNextFullArg
- ld a,c
- pop bc
- pop de
- pop hl
- call SearchLine
- jr nc,$+7
- ld hl,1
- ld b,h \ ld c,l
- dec hl \ dec bc
- ld (ThetaPrimeVar),bc
- ld b,h \ ld c,l
- ret
- ;HL is start address
- ;BC is the line number
- ;E is the NewLine byte
- FindvarInfo:
- call GetVarInfo2
- ld (ThetaPrimeVar),de
- ret nc
- ld bc,-1
- ret
- inString:
- cp 15 \ jr nz,conj
- call ParseFullArg
- push bc
- call ParseNextFullArg
- pop hl \ add hl,bc
- push hl
- call ParseNextFullArg
- ld h,b \ ld l,c
- push hl
- call GetGrammerStr
- ld (ThetaPrimeVar),bc
- pop de
- pop hl
- push bc
- call SearchString
- pop bc
- jr c,$+4
- ld h,b \ ld l,c
- or a \ sbc hl,bc
- ld b,h \ ld c,l
- ret
- conj:
- ;n = f(x) = 440*(12th root (2^(x-48))
- ;A=1, B=3, C=4, D=6, E=8, F=9, and G=11
- ;Sharp is add 1
- ;flat is minus 1
- cp 37 \ jr nz,subToken
- call ParseFullArg
- push bc
- inc hl
- ld a,(hl)
- cp $AE
- push af
- call ParseNextFullArg
- pop af
- jr nz,$+10
- pop hl
- ld (TempWord1),hl
- ld a,c
- jp PlayNoteA
- push bc
- call ParseNextFullArg
- pop hl
- pop de \ ld (TempWord1),de
- push hl
- push bc
- call PlayNoteAtHL
- pop bc
- pop hl
- cpi
- jp pe,$-9
- ret
- subToken:
- cp 12 \ jr nz,ANOVAsubset
- call ParseFullArg
- push bc
- call ParseNextFullArg
- push bc
- ld hl,(progPtr)
- inc hl
- ld (progPtr),hl
- call GetVarInfo
- jp c,Pop2Exit
- or a \ jp nz,Pop2Exit
- ld hl,(progPtr)
- ld (965Dh),hl
- ex de,hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ld (TempWord1),hl
- ld h,b \ ld l,c
- pop bc
- sbc hl,bc
- pop de
- ret c
- sbc hl,de
- jr nc,DelGoodSize
- ex de,hl
- add hl,de
- ld h,a \ cp l \ ret z
- ex de,hl
- ld hl,0
- DelGoodSize:
- add hl,bc
- push de
- ld de,(TempWord1)
- ex de,hl
- dec hl \ ld (hl),d
- dec hl \ ld (hl),e
- inc hl \ inc hl
- add hl,bc
- pop de
- push hl
- ld a,d \ or e
- jr z,$+5
- bcall(4357h)
- ld hl,(965Dh)
- ld (progPtr),hl
- pop bc
- ret
- ANOVAsubset:
- cp 59h \ jp nz,DelvarToken
- ld a,(hl)
- cp $AE
- jp nz,GravityEngine
- ret
- GravityEngine:
- call ParseFullArg
- push bc
- call ParseNextFullArg
- ld h,b \ ld l,c
- add hl,hl
- add hl,hl
- add hl,hl
- add hl,hl
- ex de,hl
- pop hl
- ld c,(hl) \ inc hl
- ld a,(hl) \ inc hl
- inc hl \ inc hl
- add hl,de
- ld b,a
- ld (TempWord3),bc
- ;hl points to object info
- ;c is Y accel
- ;a is X accel
- ld (TempWord1),hl
- ld b,0
- bit 7,c
- jr z,$+3
- dec b
- ld e,(hl) \ inc hl
- ld d,(hl)
- ex de,hl
- add hl,bc
- ex de,hl
- ld (hl),d \ dec hl
- ld (hl),e
- inc hl \ inc hl
- ld c,(hl) \ inc hl
- ld b,(hl)
- ex de,hl
- add hl,bc
- ex de,hl
- ld (hl),d \ dec hl
- ld (hl),e
- inc hl \ inc hl
- push de ;X position
- ld b,0
- ld c,a
- ld b,0
- rlca
- jr nc,$+3
- dec b
- ld e,(hl) \ inc hl
- ld d,(hl)
- ex de,hl
- add hl,bc
- ex de,hl
- ld (hl),d \ dec hl
- ld (hl),e
- inc hl \ inc hl
- ld c,(hl) \ inc hl
- ld b,(hl)
- ex de,hl
- add hl,bc
- ex de,hl
- ld (hl),d \ dec hl
- ld (hl),e
- inc hl \ inc hl
- pop bc
- srl b \ rr c
- srl b \ rr c
- srl b \ rr c
- srl b \ rr c
- srl b \ rr c
- srl b \ rr c
- jr nc,$+3
- inc bc
- srl d \ rr e
- srl d \ rr e
- srl d \ rr e
- srl d \ rr e
- srl d \ rr e
- srl d \ rr e
- jr nc,$+3
- inc de
- ;bc=y position
- ;de=x position
- ld (ThetaPrimeVar),de
- ; jr $
- ld d,(hl) \ inc hl
- ld a,63
- sub d \ dec e
- sbc a,e
- inc e
- jr nc,VelocityCheck1
- ; jr $+2
- push hl
- ld hl,(TempWord1)
- inc hl
- inc hl
- inc hl
- inc hl
- ld e,(hl) \ inc hl
- ld d,(hl)
- xor a \ sub e \ ld e,a
- sbc a,a \ sub d \ ld d,a
- push hl
- ld hl,(TempWord3+1)
- ld h,0
- ex de,hl
- sbc hl,de
- ex de,hl
- pop hl
- ld (hl),d \ dec hl
- ld (hl),e
- pop hl
- VelocityCheck1:
- ld d,(hl) \ inc hl
- ld a,95
- sub d \ dec c
- sbc a,c
- inc c
- ret nc
- ld hl,(TempWord1)
- ld e,(hl) \ inc hl
- ld d,(hl)
- xor a \ sub e \ ld e,a
- sbc a,a \ sub d \ ld d,a
- push hl
- ld hl,(TempWord3)
- ld h,0
- ex de,hl
- sbc hl,de
- ex de,hl
- pop hl
- ld (hl),d \ dec hl
- ld (hl),e
- ret
- DelvarToken:
- cp 54h \ jr nz,UnArchiveToken
- call GetVarInfo \ ret c
- bcall(4FC6h)
- ret
- UnArchiveToken:
- cp 69h \ jr nz,ArchiveToken
- call GetVarInfo \ ret c
- or a \ ret z
- bcall(4FD8h)
- bcall(42F1h)
- ex de,hl
- ld e,(hl) \ inc hl
- ld d,(hl) \ inc hl
- ex de,hl \ ld c,e \ ld b,d
- ld (ThetaPrimeVar),hl
- ret
- ArchiveToken:
- cp 68h \ jr nz,AsmToken
- call GetVarInfo \ ret c
- or a \ ret nz
- bcall(4FD8h)
- ret
- AsmToken:
- cp 6Ah \ jr nz,expr
- ; jr $
- push bc
- call GetVarName
- ; push hl
- ex de,hl
- ld de,8478h
- ldir
- xor a
- ld (de),a
- bcall(42F1h)
- ex de,hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ld a,(hl) \ inc hl \ cp $BB
- jr z,$+4
- NotASMHeader:
- ;Note: use !tibasic <<command>> on Omnimaga
- pop bc \ ret
- ld a,(hl) \ inc hl \ cp $6D
- jr nz,CheckUnsquishedHex
- dec bc \ dec bc
- ;BC is size of the data
- ;HL points to the bytes to copy
- push hl \ push bc
- ld h,b \ ld l,c
- bcall(42FDh) ;EnoughMem
- jp c,ErrMEM
- ex de,hl
- ;HL # bytes
- ;DE addr
- ld de,9D95h
- push de
- bcall(42F7h)
- pop de \ pop bc \ pop hl \ add hl,bc
- push bc \ ldir \ pop de
- jr CallProg-7
- CheckUnsquishedHex:
- cp 6Ch \ jr nz,NotASMHeader
- jr NotASMHeader
- ;===============================================================
- ;If unsquished, do this
- ;DE=Size
- ;(progPtr) adjusted
- ;===============================================================
- ld de,9D95h \ push de
- bcall(4E79h)
- pop hl \ or a \ ex de,hl \ sbc hl,de
- ex de,hl
- ld hl,(progPtr)
- add hl,de
- ld (progPtr),hl
- ;===============================================================
- CallProg:
- pop bc
- push de
- ; add hl,de
- call 9D95h
- ld hl,(progPtr)
- pop de
- or a
- sbc hl,de
- ld (progPtr),hl
- ld hl,9D95h
- ;Delmem: HL address
- ; DE # of bytes
- bcall(4357h)
- ret
- expr:
- cp 2Ah \ jr nz,AsmPrgm
- call ParseFullArg
- ld hl,(progPtr) \ push hl
- ld (progPtr),bc
- call ParseCondition
- pop hl
- ld (progPtr),hl
- ret
- AsmPrgm:
- cp 6Ch \ jr nz,OMNom
- push bc
- ld b,h \ ld c,l
- call ConvHexTo86ECh
- ex de,hl
- ld (progPtr),hl
- pop bc
- jp 86ECh
- OMNom:
- cp 5 \ jr nz,BBrandInt
- dec hl \ dec hl \ dec hl
- ld a,(hl) \ cp 4Dh \ ret nz
- dec hl
- ld a,(hl) \ cp 4Fh \ ret nz
- call ParseFullArg
- ld a,c \ and 3
- add a,12
- out (16),a
- ret
- BBrandInt:
- cp 10 \ jr nz,BBLCM
- call ParseFullArg
- push bc
- push bc
- call ParseNextFullArg
- ld h,b \ ld l,c
- pop bc
- or a \ sbc hl,bc \ ld b,h \ ld c,l
- ld hl,(randSeed)
- ld a,r \ ld d,a
- ld a,r \ ld e,a
- add hl,de
- ld (randSeed),hl
- call HL_Div_BC
- pop hl \ add hl,de
- ld b,h \ ld c,l
- ret
- BBLCM:
- cp 8 \ jr nz,BBGCD
- call ParseFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- pop de
- LCM_BC_DE:
- push de
- call DE_Times_BC
- pop de
- push hl
- ex de,hl
- call GCDHL_BC
- pop hl
- call HL_Div_BC
- ld b,h \ ld c,l
- ret
- BBGCD:
- cp 9
- ret nz
- call ParseFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- pop hl
- ;===============================================================
- GCDHL_BC:
- ;===============================================================
- ;Inputs:
- ; hl,bc
- ;Outputs:
- ; a is 0
- ; bc is the Greatest Common Divisor
- ; de is 0
- ;Destroys:
- ; hl
- ;===============================================================
- or a \ sbc hl,bc
- ret z
- add hl,bc
- jr nc,$+8
- ld a,h
- ld h,b
- ld b,a
- ld a,l
- ld l,c
- ld c,a
- call HL_Div_BC
- or d \ or e \ ret z
- ld h,b \ ld l,c
- ld b,d \ ld c,e
- jr $-10
- CircleToken:
- cp $A5
- jr nz,PauseToken
- call ParseFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- pop de
- ld d,c
- push de
- call ParseNextFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- ld b,c \ ld c,0
- ; jr $
- cp 2Bh \ push bc
- call z,ParseNextFullArg ;CD****
- pop af
- ld (TempWord1),a
- ld b,c
- ld (TempWord1+1),bc
- pop bc
- pop de
- jp FastCircle
- PauseToken:
- cp $D8
- jr nz,PxlTestToken
- push bc
- ld a,(hl) \ cp $CE \ jr nz,Pause
- bit 2,(iy+33)
- res 2,(iy+33)
- inc hl
- jr z,Pauseif
- jr PauseNotIf
- Pause:
- call CheckStatus
- push af
- res 2,(iy+33)
- call ParseFullArg
- PauseMainLoop:
- ld de,411
- PauseSubLoop:
- bit 2,(iy+34)
- call z,CheckStatus
- call z,ONErr
- dec de \ ld a,d \ or e \ jr nz,PauseSubLoop
- dec bc \ ld a,b \ or c \ jr nz,PausemainLoop
- pop af \ ld a,0
- adc a,a
- out (20),a
- pop bc \ ret
- PauseIf:
- call PauseIfLoop
- jr nz,PauseIf
- pop bc \ ret
- PauseNotIf:
- call PauseIfLoop
- jr z,PauseNotIf
- pop bc \ ret
- PauseIfLoop:
- ld (progPtr),hl \ push hl
- call ParseCondition
- or a \ sbc hl,hl \ sbc hl,bc
- pop hl
- ret
- PxlTestToken:
- cp 13h
- jr z,PxlTokens+10
- PxlTokens:
- cp $A1
- jr c,prgmToken
- cp $A4
- jr nc,prgmToken
- sub $A0
- push af
- call ParseFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- ld a,c
- pop bc
- ld b,a
- pop de
- PlotPixel:
- push de
- call GetPixelLoc
- pop de
- bit 4,(iy+34)
- ld bc,0
- jr z,$+3
- inc c
- ret nc
- ld e,a
- and (hl)
- jr z,$+4
- ld c,1
- ld a,e
- dec d
- jr nz,$+5
- or (hl) \ ld (hl),a
- ret
- dec d
- jr nz,$+6
- cpl \ and (hl) \ ld (hl),a
- ret
- dec d
- jr nz,$+4
- xor (hl) \ ld (hl),a \ ret
- prgmToken:
- cp $5F ;FE5F
- jr nz,DispToken ;2013
- ld a,(hl) \ inc hl
- call VarPointer
- push hl \ push af
- call ParseFullArg ;CD****
- ld de,(965Bh)
- ld hl,(progPtr) ;2A7298
- or a \ sbc hl,de
- push hl ;E5
- ex de,hl \ sbc hl,bc
- push hl
- ld (progPtr),bc ;ED437298
- call ParserNext ;CD****
- pop hl
- pop de ;D1
- push hl
- ld hl,(965Bh)
- add hl,de
- ld (progPtr),hl ;227298
- pop de
- ld hl,(965Bh)
- sbc hl,de
- ex de,hl
- pop af \ pop hl
- ret nc
- ld (hl),e \ inc hl
- ld (hl),d
- ret ;C9
- DispToken:
- cp $DE
- jr nz,TextToken
- call ParseFullArg
- ld (BufPtr),bc
- ret
- TextToken:
- cp 93h
- jp nz,PtOff
- ld a,(hl)
- res 0,(iy+33)
- cp 10
- jr nz,$+11
- SlowText:
- set 0,(iy+33)
- inc hl
- ld (progPtr),hl
- ld a,(hl)
- cp $AE
- jr nz,FindingTextStr
- inc hl
- ld (progPtr),hl
- call LoadTextCoordinates
- call ParseNextFullArg ;CD****
- push bc
- ld hl,(progPtr)
- ld a,(hl)
- cp 2Bh
- ld c,10
- call z,ParseNextFullArg+3
- pop hl
- call ConvNumBase
- ;===============================================================
- PutSM:
- ;===============================================================
- ;Inputs:
- ; hl points to the string to display
- ; bc is the size of the string
- ;===============================================================
- ld a,b \ or c \ ret z
- push bc
- push hl
- ld a,(hl)
- call PutSC
- pop hl
- pop bc
- cpi
- jp pe,PutSM+3
- ret
- FindingTextStr:
- call LoadTextCoordinates
- inc hl
- ld a,(hl)
- cp $AE
- jr nz,$+12
- ld (progPtr),hl
- call ParseNextFullArg
- ld a,c
- jp PutSC
- call ParseNextFullArg ;CD****
- ld h,b
- ld l,c
- call GetGrammerText
- push hl
- ld hl,(progPtr)
- ld a,(hl)
- cp 2Bh
- jr nz,$+7
- push de
- call ParseNextFullArg+3 ;CD****
- pop de
- ex de,hl
- call PutSM
- pop bc
- ret
- ;===============================================================
- LoadTextCoordinates:
- ;===============================================================
- ld a,(hl)
- cp 11
- jr nz,$+6
- ld (progPtr),hl
- ret
- call ParseFullArg
- ld a,c
- ld (textRow),a
- call ParseNextFullArg ;CD****
- ld a,c
- ld (textCol),a
- ret
- ;===============================================================
- PtOff:
- cp 9Fh
- jp nz,LineToken
- call ParseFullArg
- ld a,c \ and 7
- res 0,(iy+33)
- bit 3,c
- jr z,$+6
- set 0,(iy+33)
- push af
- call ParseNextFullArg ;CD****
- bit 0,(iy+33)
- jr z,$+8
- call ConvHexTo86ECh
- ld bc,86ECh
- push bc
- call ParseNextFullArg ;CD****
- push bc
- call ParseNextFullArg ;CD****
- pop de
- ld d,c
- push de
- call ParseNextFullArg ;CD****
- ; push bc
- call ParseNextFullArg ;CD****
- ; pop hl
- ld l,1
- ld h,c
- pop bc
- ld a,c \ cp 64 \ jr nc,BadSprite
- add a,h \ dec a \ sub 64
- jr c,HeightIsFinePtOff
- ld d,a \ ld a,h \ sub d \ ld h,a \ dec h
- HeightIsFinePtOff:
- pop de
- ld a,b
- sub 97 \ jr nc,BadSprite
- ld a,l \ add a,a \ rlca \ rla ;hehe
- add a,b \ sub 97
- jr nc,BadSprite
- pop af
- jr DrawPixelCoordSprite
- BadSprite:
- pop af \ ret
- ;===============================================================
- DrawPixelCoordSprite:
- ;===============================================================
- ;Inputs:
- ; A is the method:
- ; 0=Overwrite
- ; 1=AND
- ; 2=XOR
- ; 3=OR
- ; 4=DataSwap.......Does nothing
- ; 5=Erase
- ; B is the X-coordinate
- ; C is the Y-Coordinate
- ; DE points to the sprite
- ; H is the height
- ; L is the width ;not added yet
- ;===============================================================
- di
- ex af,af'
- push hl
- ld a,b
- ld b,0
- ld h,b \ ld l,c
- add hl,hl \ add hl,bc
- add hl,hl \ add hl,hl
- push hl
- ld c,a
- srl c \ srl c \ srl c
- ld b,0
- ld hl,(BufPtr)
- add hl,bc
- pop bc
- add hl,bc
- push hl
- and 7
- ld (TempWord1),a
- exx
- pop hl
- ld bc,11
- exx
- pop bc
- ex af,af'
- ;===============================================================
- ;HL'=location to draw to
- ;B=height
- ;C is not needed
- ;A=method
- ;DE=sprite location
- or a
- jr nz,DrawSpriteAND-3
- DrawSpriteOverwrite:
- exx
- ld de,$FF00
- call ShiftDE
- ld (TempWord3),de
- exx
- DrawSpriteOverwriteLoop:
- ld a,(de)
- inc de
- exx
- ld d,0 \ ld e,a
- call ShiftDE
- push de
- ld de,(TempWord3)
- ld a,(hl)
- and e
- pop de
- or e \ ld (hl),a
- inc hl
- push de
- ld de,(TempWord3)
- ld a,(hl)
- and d
- pop de
- or d \ ld (hl),a
- add hl,bc
- exx
- djnz DrawSpriteOverWriteLoop
- ret
- dec a
- jr nz,DrawSpriteXOR-3
- DrawSpriteAND:
- ld a,(de)
- inc de
- exx
- ld d,255 \ ld e,a
- call ShiftDE
- ld a,e
- and (hl) \ ld (hl),a
- inc hl
- ld a,d
- and (hl) \ ld (hl),a
- add hl,bc
- exx
- djnz DrawSpriteAND
- ret
- dec a
- jr nz,DrawSpriteOR-3
- DrawSpriteXOR:
- ld a,(de)
- inc de
- exx
- ld d,0 \ ld e,a
- call ShiftDE
- ld a,e
- xor (hl) \ ld (hl),a
- inc hl
- ld a,d
- xor (hl) \ ld (hl),a
- add hl,bc
- exx
- djnz DrawSpriteXOR
- ret
- dec a
- jr nz,DrawSpriteSwap-3
- DrawSpriteOR:
- ld a,(de)
- inc de
- exx
- ld d,0 \ ld e,a
- call ShiftDE
- ld a,e
- or (hl) \ ld (hl),a
- inc hl
- ld a,d
- or (hl) \ ld (hl),a
- add hl,bc
- exx
- djnz DrawSpriteOR
- ret
- dec a
- jr nz,DrawSpriteErase
- DrawSpriteSwap:
- ret
- DrawSpriteErase:
- ld a,(de)
- cpl
- inc de
- exx
- ld d,255 \ ld e,a
- call ShiftDE
- ld a,e
- and (hl) \ ld (hl),a
- inc hl
- ld a,d
- and (hl) \ ld (hl),a
- add hl,bc
- exx
- djnz DrawSpriteErase
- ret
- ShiftDE:
- ld a,(TempWord1)
- or a \ ret z
- ld b,a
- rr e \ rr d
- jr nc,$+4
- set 7,e
- djnz $-8
- ret
- LineToken:
- cp 9Ch
- jp nz,LeftParantheses
- ld a,(hl)
- cp $AE
- jr nz,NLinePrime
- ;b,e need to be y
- ;c,d need to be x
- call ParseNextFullArg+3
- push bc
- call ParseNextFullArg ;CD****
- pop de
- ld d,c
- push de
- call ParseNextFullArg ;CD****
- ld a,c \ push af
- call ParseNextFullArg ;CD****
- pop af \ ld b,a
- push bc
- ld a,(hl)
- cp 2Bh
- ld c,1
- call z,ParseNextFullArg ;CD****
- ld a,c
- pop de
- pop bc
- jp DrawLine
- ;======================================
- NLinePrime:
- ;======================================
- call ParseFullArg
- ld a,c \ sub 96 \ jr nc,BadRect+1
- push bc
- call ParseNextFullArg
- ld a,c \ sub 64 \ jr nc,BadRect
- push bc
- call ParseNextFullArg
- pop de
- ld a,c \ sub 65 \ jr nc,BadRect
- add a,e
- jr nc,$+7
- ld b,a \ inc b
- ld a,c \ sub b
- ld c,a
- ld d,c \ push de
- call ParseNextFullArg
- pop de \ pop hl
- ld a,c \ sub 97 \ jr nc,BadRect+1
- add a,l
- jr nc,$+7
- ld b,a \ inc b
- ld a,c \ sub b
- ld c,a
- ld h,c \ push hl \ push de
- call ParseNextFullArg
- ld a,c
- pop bc \ pop de
- jp DrawRectToGraph
- BadRect:
- pop af
- jp EndOfCommand
- ;======================================
- LeftParantheses:
- ;Read a byte
- cp 16
- jr nz,LeftBracket
- call ParseFullArg
- ld h,b
- ld l,c
- ld c,(hl)
- ld b,0
- ret
- LeftBracket:
- ;Read a word (little endian)
- cp 8
- jr nz,iPart
- call ParseFullArg
- ld h,b
- ld l,c
- ld c,(hl)
- inc hl
- ld b,(hl)
- ret
- iPart:
- ;Write a word (little endian)
- cp $B9
- jr nz,int
- call ParseFullArg
- push bc
- call ParseNextFullArg ;CD****
- pop hl
- ld e,(hl)
- ld (hl),c
- inc hl
- ld d,(hl)
- ld (hl),b
- ld b,d
- ld c,e
- ret
- int:
- ;Write a byte
- cp $B1
- jr nz,GetToken
- call ParseFullArg
- push bc
- call ParseNextFullArg ;CD****
- pop hl
- ld e,(hl)
- ld (hl),c
- ld c,e
- ld b,0
- ret
- GetToken:
- cp $E8
- jr nz,RepeatToken
- call GetVarName
- ex de,hl
- ld de,8478h
- ldir
- xor a
- ld (de),a
- bcall(_ChkFindSym)
- VarTokenStepIn:
- jr nc,$+6
- ld bc,0
- ret
- inc de
- inc de
- ld c,a
- ld (ThetaPrimeVar),bc
- ld b,d
- ld c,e
- ret
- RepeatToken:
- cp $D2 \ jr nz,WhileToken
- push hl
- ld de,(965Bh) \ sbc hl,de
- ex de,hl
- pop hl
- call EndOfLine
- ;DE is the offset to the condition
- ld (progPtr),hl
- bit 2,(iy+33)
- res 2,(iy+33)
- jr nz,NotRepeatLoop
- RepeatLoop:
- call RepeatLooper
- jr z,RepeatLoop
- ExitRepeat:
- ld (progPtr),hl
- ret
- NotRepeatLoop:
- call RepeatLooper
- jr nz,NotRepeatLoop
- jr ExitRepeat
- RepeatLooper:
- push de
- call ParserNext
- ld hl,(progPtr)
- pop de
- push de
- push hl
- ld hl,(965Bh) \ add hl,de
- ld (progPtr),hl
- pop hl \ push hl
- push bc
- call ParseCondition
- ld a,b \ or c
- Pop3Exit:
- pop bc
- Pop2Exit:
- pop hl
- Pop1Exit:
- pop de
- ret
- WhileToken:
- cp $D1 ;FED1
- jr nz,EndToken ;201A
- ld de,(965Bh)
- sbc hl,de
- bit 2,(iy+33)
- res 2,(iy+33)
- jr nz,NotWhileLoop
- WhileLoop:
- push hl
- ld de,(965Bh) \ add hl,de
- ld (progPtr),hl ;227298
- call ParseCondition
- ld a,b \ or c
- jr z,EndWhileLoop
- call ParserNext
- pop hl
- jr WhileLoop
- NotWhileLoop:
- push hl
- ld de,(965Bh) \ add hl,de
- ld (progPtr),hl ;227298
- call ParseCondition
- ld a,b \ or c
- jr nz,EndWhileLoop
- call ParserNext
- pop hl
- jr NotWhileLoop
- EndWhileLoop:
- pop de ;D1
- call FindEndToken ;CD****
- ld (progPtr),hl ;227298
- ret ;C9
- EndToken:
- cp $D4 ;FED4
- jr nz,StopToken ;20**
- pop de ;D1
- ret ;C9
- StopToken:
- cp $D9 ;FED9
- jr nz,PtOn ;20**
- BreakProgram:
- xor a
- ld hl,(progPtr)
- dec hl ;2B
- ld (965Dh),hl ;225D96
- ld sp,(SPSave) ;ED7B8698
- di
- im 1
- or a \ ret z
- ld b,a
- ld a,(9652h)
- cp 5
- ld a,b
- jr nz,$+4
- or 128
- bcall(44D7h)
- ret ;C9
- ErrorJump:
- bit 3,(iy+33)
- ret nz
- push bc
- push de
- push hl
- set 3,(iy+33)
- ld hl,(parseError)
- ld a,h \ or l
- ld a,(8595h)
- call z,GramHandl
- jr z,GramHandled
- ld c,a \ ld b,0
- ld de,(progPtr) ;2A7298
- push de ;E5
- ld (progPtr),hl ;ED437298
- call ParserNext ;CD****
- pop hl ;E1
- ld (progPtr),hl ;227298
- GramHandled:
- pop hl
- pop de
- pop bc
- res 3,(iy+33)
- ret
- PtOn:
- cp 9Eh ;FE9E
- jp nz,QuoteToken ;C2****
- ; jr $
- call ParseFullArg
- ld a,c \ and 7
- res 0,(iy+33)
- bit 3,c
- ; jr nz,$
- jr z,$+6
- set 0,(iy+33)
- push af
- call ParseNextFullArg ;CD****
- bit 0,(iy+33)
- jr z,$+8
- call ConvHexTo86ECh
- ld bc,86ECh
- push bc ;C5
- call ParseNextFullArg ;CD****
- ld (TempWord2),bc
- ld b,0 ;0600
- ld h,b ;60
- ld l,c ;69
- add hl,hl ;29
- add hl,bc ;09
- add hl,hl ;29
- add hl,hl ;29
- push hl ;E5
- call ParseNextFullArg ;CD****
- pop hl ;E1
- add hl,bc ;09
- ld bc,(BufPtr) ;014093
- add hl,bc ;09
- push hl ;E5
- call ParseNextFullArg ;CD****
- ld b,c ;41
- push bc ;C5
- call ParseNextFullArg ;CD****
- pop af ;F1
- ld b,a ;47
- ld a,(TempWord2)
- add a,c \ dec a \ sub 64
- jr c,HeightIsFinePtOn
- ld d,a \ ld a,c \ sub d \ ld c,a \ dec c
- HeightIsFinePtOn:
- pop hl ;E1
- pop de ;D1
- ld a,(TempWord2) \ inc a \ sub 64 \ jp nc,BadSprite
- pop af ;F1
- ;===========================================================
- DrawSpriteXxY:
- ;===========================================================
- ;Inputs:
- ; A is the method:
- ; 0=Overwrite
- ; 1=AND
- ; 2=XOR
- ; 3=OR
- ; 4=Swap
- ; 5=Erase
- ; B is the width (in bytes)
- ; C is the height (in pixels)
- ; DE points to the sprite data
- ; HL points to the output location
- ;Outputs:
- ; HL is A*12 larger (next sprite down?)
- ; DE points to the next byte after the sprite data
- ; A is 0
- ; B is not changed
- ; C is 12-B
- ;===========================================================
- push af ;F5
- ld a,c ;79
- di ;F3
- ex af,af' ;08
- ld a,12 ;3E0C
- sub b ;90
- ld c,a ;4F
- pop af ;F1
- OverwriteXxY:
- or a ;B7
- jr nz,ANDXxY ;2010
- ex af,af' ;08
- ex de,hl ;EB
- push bc ;C5
- ldi ;EDA1
- inc bc ;03
- djnz $-3 ;10FB
- ex de,hl ;EB
- add hl,bc ;09
- pop bc ;C1
- dec a ;3D
- jr nz,$-11 ;20F3
- ret ;C9
- ANDXxY:
- dec a ;3D
- jr nz,XORXxY ;2011
- ex af,af' ;08
- push bc ;C5
- push af ;F5
- ld a,(de) ;1A
- and (hl) ;A6
- ld (hl),a ;77
- inc de ;13
- inc hl ;23
- djnz $-5 ;10F9
- add hl,bc ;09
- pop af ;F1
- pop bc ;C1
- dec a ;3D
- jr nz,$-13 ;20F1
- ret ;C9
- XORXxY:
- dec a ;3D
- jr nz,ORXxY ;2011
- ex af,af' ;08
- push bc ;C5
- push af ;F5
- ld a,(de) ;1A
- xor (hl) ;AE
- ld (hl),a ;77
- inc de ;13
- inc hl ;23
- djnz $-5 ;10F9
- add hl,bc ;09
- pop af ;F1
- pop bc ;C1
- dec a ;3D
- jr nz,$-13 ;20F1
- ret ;C9
- ORXxY:
- dec a ;3D
- jr nz,SwapXxY ;2011
- ex af,af' ;08
- push bc ;C5
- push af ;F5
- ld a,(de) ;1A
- or (hl) ;B6
- ld (hl),a ;77
- inc de ;13
- inc hl ;23
- djnz $-5 ;10F9
- add hl,bc ;09
- pop af ;F1
- pop bc ;C1
- dec a ;3D
- jr nz,$-13 ;20F1
- ret ;C9
- SwapXxY:
- dec a ;3D
- jr nz,EraseXxY ;2011
- ex af,af' ;08
- ld c,12 ;0E0C
- push bc ;C5
- push af ;F5
- ld a,(de) ;1A
- ldi ;EDA0
- dec hl ;2B
- ld (hl),a ;77
- inc hl ;23
- djnz $-6 ;10F8
- add hl,bc ;09
- pop af ;F1
- pop bc ;C1
- dec a ;3D
- jr nz,$-14 ;20F0
- ret ;C9
- EraseXxY:
- ex af,af' ;08
- push bc ;C5
- push af ;F5
- ld a,(de) ;1A
- cpl ;2F
- and (hl) ;A6
- ld (hl),a ;77
- inc de ;13
- inc hl ;23
- djnz $-6 ;10F8
- add hl,bc ;09
- pop af ;F1
- pop bc ;C1
- dec a ;3D
- jr nz,$-14 ;20F0
- ret ;C9
- ;===========================================================
- QuoteToken:
- cp 2Ah ;FE2A
- jr nz,GetKeyToken ;20**
- push hl ;E5
- call GetGrammerStr ;CD****
- ld (progPtr),hl ;227298
- ld (ThetaPrimeVar),bc ;ED436A80
- pop bc ;C1
- ret ;C9
- GetKeyToken:
- cp $AD ;FEAD
- jp nz,IfToken ;20**
- ld a,(hl) \ cp 16
- jr nz,GetKey
- call ParseNextFullArg+3
- ld a,c
- CheckKey:
- cp 41
- jr nz,$+7
- call CheckStatus
- jr KeyEnd
- dec c \ ld a,c \ and 7
- ld b,a \ inc b \ ld a,7Fh
- rlca
- djnz $-1
- ld d,a
- srl c \ srl c \ srl c
- ld b,c \ inc b \ ld a,7Fh
- rlca
- djnz $-1
- out (1),a
- push af \ pop af
- in a,(1)
- cp d
- KeyEnd:
- ld bc,0
- jr nz,$+3
- inc c
- ret
- ;===============================================================
- GetKey:
- ;===============================================================
- ;Outputs:
- ; a is a value from 0 to 56 that is the keypress
- ; bc is also the key press
- ; d has a bit reset, the rest are set (this is the last key group tested)
- ; e is a with a mask of %11111000
- ; hl is not modified
- ;===============================================================
- ld a,-2
- out (1),a
- push af \ pop af
- in a,(1) \ cpl
- ld b,0
- or a \ jr z,JustCheckDaKeys
- ld d,a
- ld c,16 \ cp 15 \ ret z
- ld c,5
- ld a,3 \ and d \ cp 3 \ ret z \ inc c
- ld a,5 \ and d \ cp 5 \ ret z \ inc c
- ld a,10 \ and d \ cp 10 \ ret z \ inc c
- ld a,12 \ and d \ cp 12 \ ret z
- JustCheckDaKeys:
- ld c,0
- ld de,$7FF8 ;11F87F
- KeyLoop:
- ld a,8 ;3E08
- add a,e ;83
- ld e,a ;5F
- rlc d ;CB02
- ld a,d ;7A
- out (1),a ;D301
- sub 7Fh ;D67F
- jr z,CheckOnPress ;C8
- nop \ nop ;0000 in case of 15MHz mode
- in a,(1) ;DB01
- inc a ;3C
- jr z,KeyLoop ;28EC
- dec a ;3D
- inc c ;0C
- or a ;B7 to reset c flag
- rra ;1F
- jr c,$-3 ;38FB
- ld a,e ;83
- add a,c ;81
- ld c,a
- cp 41
- ret c
- CheckOnPress:
- call CheckStatus
- ret nz
- ld c,41 \ ld a,c
- ret ;C9
- IfToken:
- cp $CE ;FECE
- jr nz,VarToken ;20**
- push bc ;C5
- call ParseCondition ;CD****
- or a ;B7
- sbc hl,hl ;ED62
- sbc hl,bc ;ED42
- pop bc ;C1
- bit 2,(iy+33)
- jr z,$+7
- res 2,(iy+33)
- ccf
- ret c ;D8
- ld hl,(progPtr) ;2A7298
- inc hl ;23
- ld a,(hl) ;7E
- push bc ;C5
- cp $CF ;FECF
- jr nz,NoThenToken ;20**
- call FindEndToken ;CD****
- ld (progPtr),hl ;227298
- NoThenToken:
- call EndOfLine ;CD****
- ld (progPtr),hl ;227298
- pop bc ;C1
- ret ;C9
- VarToken:
- call VarPointer
- jr nc,StoToken
- ld c,(hl) ;4E
- inc hl ;23
- ld b,(hl) ;46
- ex de,hl ;EB
- ParseFullArg:
- ld hl,(progPtr)
- ld a,(hl)
- call EndOArg
- ret z
- cp 29h \ ret z
- call ParseArg ;CD****
- jr ParseFullArg
- ParseNextFullArg:
- ld hl,(progPtr)
- inc hl
- ld (progPtr),hl
- jr ParseFullArg
- ParseCondition:
- call ParseFullArg
- cp 3Fh \ ret z
- ld hl,(progPtr) ;2A7298
- inc hl ;23
- ld (progPtr),hl
- jr ParseCondition
- StoToken:
- cp 4 ;FE04
- jr nz,Return ;20**
- ld a,(hl) ;7E
- inc hl ;23
- cp 44
- jr nz,NotOSVar
- push bc
- ld a,(hl)
- ld (8479h),a
- inc hl
- ld (progPtr),hl
- ld hl,0
- ld (847Ah),hl
- ld h,b \ ld l,c
- bcall(4792h)
- rst 10h
- jr nc,$+5
- bcall(430Fh)
- ld a,b
- or a \ jr nz,Archived
- ld bc,9
- ld hl,8483h
- ldir
- Archived:
- pop bc
- ret
- NotOSVar:
- call VarPointer
- jr nc,NotAVar
- ld (hl),c ;71
- inc hl ;23
- ld (hl),b ;70
- ex de,hl ;EB
- NotAVar:
- ld (progPtr),hl ;227298
- ret ;C9
- Return:
- cp $D5 ;FED5
- jr nz,LblToken ;2005
- call EndOfLine ;CD****
- ld c,l ;4D
- ld b,h ;44
- ret ;C9
- LblToken:
- cp $D6 ;FED6
- jr nz,GotoToken ;20**
- push hl ;E5
- call ParseFullArg ;CD****
- pop hl ;E1
- push bc ;C5
- call GetGrammerStr ;CD****
- pop hl ;E1
- ld de,86ECh ;11EC86
- push de ;D5
- ld a,3Ah ;3E3A
- ld (de),a ;12
- inc de ;13
- push bc ;C5
- ldir ;EDB0
- dec de ;1B
- ld a,3Fh ;3E3F
- ld (de),a ;12
- pop bc ;C1
- inc bc ;03
- pop de ;D1
- ld hl,(progStart) ;2A7298
- call SearchString ;CD****
- ld b,h ;44
- ld c,l ;4D
- ret ;C9
- GotoToken:
- cp $D7 ;FED7
- jr nz,DispGraph ;2008
- call ParseFullArg ;CD****
- ld (progPtr),bc ;ED437298
- ret ;C9
- DispGraph:
- cp $DF ;FEDF
- jr nz,Number
- ld a,(hl)
- ld hl,(BufPtr)
- call EndOArg
- jr z,$+7
- call ParseFullArg
- ld h,b \ ld l,c
- jp GraphToLCD+3 ;CA****
- Number:
- cp 30h ;FE30
- jr c,Math ;3819
- cp 3Ah ;FE3A
- jr nc,Math ;3007
- call ConvRStr ;CD****
- ld (progPtr),hl ;227298
- call ParseFullArg ;CD****
- Math:
- Sqrt:
- cp $BC
- jr nz,Cos
- ld a,(hl)
- inc hl
- cp $AE
- push af
- jr nz,$+5
- ld (progPtr),hl
- call ParseFullArg
- ld h,b
- ld l,c
- call SqrtHL
- ld c,a
- pop af
- jr nz,$+15
- ld a,l
- cp 2 \ ret c
- ld a,c
- scf
- sbc hl,bc
- add hl,bc
- jr c,$+3
- inc bc
- ret
- ld (ThetaPrimeVar),hl
- ret
- Cos:
- cp $C4 ;FEC4
- jr nz,Sin ;2004
- ld a,64 ;3E40
- jr $+7 ;1805
- Sin:
- cp $C2 ;FEC2
- jr nz,absToken ;2022
- xor a ;AF
- push af ;F5
- call ParseFullArg ;CD****
- pop af ;F1
- add a,c ;81
- Sine:
- di ;F3 4
- add a,a ;87 4
- ld d,a ;57 4
- cpl ;2F 4
- ld e,a ;5F 4
- ex af,af' ;08 4
- xor a ;AF 4
- ld b,8 ;0608 7
- rrc e ;CB0B 64
- jr nc,$+3 ;3001 88|96
- add a,d ;82 --
- rra ;1F 32
- djnz $-6 ;10F8 99
- adc a,a ;8F 4
- ld c,a ;4F 4
- ret z ;C8 11|5
- ex af,af' ;08 4
- ret nc ;D0 11|5
- ld a,c ;79 4
- neg ;ED44 8
- ld c,a ;4F 4
- dec b ;05 4
- ret ;C9 10
- absToken:
- cp $B2 \ jr nz,Negative
- call ParseFullArg ;CD****
- bit 7,b \ ret z
- jr Negative+7
- Negative:
- cp $B0 ;FEB0
- jr nz,Add ;20**
- call ParseFullArg ;CD****
- ld a,b \ cpl \ ld b,a
- ld a,c \ cpl \ ld c,a
- inc bc
- ret ;C9
- Add:
- cp 70h ;FE70
- jr nz,Subtract ;20**
- push bc ;C5
- call ParseFullArg ;CD****
- pop hl ;E1
- xor a ;AF
- add hl,bc ;09
- ld b,h ;44
- ld c,l ;4D
- ld h,a ;67
- adc a,a ;8F
- ld l,a ;6F
- ld (ThetaPrimeVar),hl ;226A80
- ret ;C9
- Subtract:
- cp 71h ;FE71
- jr nz,Cubed ;20**
- push bc ;C5
- call ParseFullArg ;CD****
- pop hl ;E1
- xor a ;AF
- sbc hl,bc ;ED42
- ld b,h ;44
- ld c,l ;4D
- sbc hl,hl ;ED62
- ld (ThetaPrimeVar),hl ;226A80
- ret ;C9
- Cubed:
- Squared:
- cp 13 ;FE0D
- jr nz,Multiply
- ld d,b
- ld e,c
- jr $+11
- Multiply:
- cp 82h ;FE82
- jr nz,Comment ;20**
- push bc ;C5
- call ParseFullArg ;CD****
- pop de ;D1
- call DE_Times_BC ;CD****
- ld b,h ;44
- ld c,l ;4D
- ld (ThetaPrimeVar),de ;ED536A80
- ret ;C9
- Comment:
- cp 3Ah ;FE3A
- jr nz,$+8 ;CA****
- SkipLine:
- call EndOfLine
- jp ParseArg+3
- cp 83h
- jr nz,Logic ;FE83
- ld a,(hl) ;7E
- cp 93h \ jp z,SlowText
- cp 83h ;FE83
- jr z,SkipLine ;CA****
- cp 29h \ jr nz,Divide
- push bc ;C5
- call ParseNextFullArg ;CD****
- pop hl ;E1
- call HL_SDiv_BC ;CD****
- ld b,h ;44
- ld c,l ;4D
- ld (ThetaPrimeVar),de ;ED536A80
- ret ;C9
- Divide:
- push bc ;C5
- call ParseFullArg ;CD****
- pop hl ;E1
- call HL_Div_BC ;CD****
- ld b,h ;44
- ld c,l ;4D
- ld (ThetaPrimeVar),de ;ED536A80
- ret ;C9
- Logic:
- Equals:
- cp 6Ah ;FE6A
- jr nz,moreLogic
- push bc ;C5
- factorialStepIn:
- call ParseFullArg ;CD****
- pop hl ;E1
- xor a ;AF
- sbc hl,bc ;ED42
- ld b,a ;47
- ld c,a ;4F
- jr nz,$+3 ;2001
- inc c ;1C
- ret ;C9
- moreLogic:
- push af
- push bc
- call ParseFullArg
- pop hl
- pop af
- notLogic:
- cp $B8
- jr nz,$+9
- ld a,b \ cpl \ ld b,a
- ld a,c \ cpl \ ld c,a
- ret
- andLogic:
- cp 40h
- jr nz,$+9
- ld a,h \ and b \ ld b,a
- ld a,l \ and c \ ld c,a
- ret
- orLogic:
- cp 3Ch
- jr nz,$+9
- ld a,h \ or b \ ld b,a
- ld a,l \ or c \ ld c,a
- ret
- xorLogic:
- cp 3Dh
- jr nz,$+9
- ld a,h \ xor b \ ld b,a
- ld a,l \ xor c \ ld c,a
- ret
- Less:
- cp 6Bh ;FE6B
- jr nz,Greater
- xor a ;AF
- sbc hl,bc ;ED42
- ld b,a ;47
- adc a,a ;8F
- ld c,a ;4F
- ret ;C9
- Greater:
- cp 6Ch ;FE6C
- jr nz,LessOrEqual
- xor a ;AF
- scf ;37
- sbc hl,bc ;ED42
- ccf ;3F
- ld b,a ;47
- adc a,a ;8F
- ld c,a ;4F
- ret ;C9
- LessOrEqual:
- cp 6Dh ;FE6D
- jr nz,MoreOrEqual
- xor a ;AF
- scf ;37
- sbc hl,bc ;ED42
- ld b,a ;47
- adc a,a ;8F
- ld c,a ;4F
- ret ;C9
- MoreOrEqual:
- cp 6Eh ;FE6E
- jr nz,NotEqual
- xor a ;AF
- sbc hl,bc ;ED42
- ccf ;3F
- ld b,a ;47
- adc a,a ;8F
- ld c,a ;4F
- ret ;C9
- NotEqual:
- cp 6Fh ;FE6F
- jr nz,Exit
- xor a ;AF
- sbc hl,bc ;ED42
- ld b,a ;47
- ld c,a ;4F
- jr z,$+3 ;2801
- inc c ;1C
- Exit:
- ret ;C9
- EndOfCommand:
- ld hl,(progPtr)
- inc hl
- ld a,(hl) \ call EndOArg
- jr nz,EndOfCommand+3
- ld (progPtr),hl
- ret
- EndOArg:
- cp 4 \ ret z
- EndOArgNotSto:
- cp 3Fh \ ret z
- ; cp 3Ah \ ret z
- cp 3Eh \ ret z
- cp 2Bh \ ret z
- or a
- ret
- ;====================================
- ;====================================
- ;This section contains calls and data
- ;used by Grammer.
- ;====================================
- ;====================================
- ;
- ;===============================================================
- FindEndToken:
- ;===============================================================
- ;Input:
- ; HL is an address
- ;Outputs:
- ; HL points to the byte after the proper End token
- ;===============================================================
- ld b,1
- SearchEndLoop:
- inc hl
- ld a,(hl)
- sub $CF ;Then
- jr c,SearchEndLoop ;**Just to save time
- jr z,AddNewEnd
- dec a
- dec a \ jr z,AddNewEnd ;While
- dec a \ jr z,AddNewEnd ;Repeat
- dec a \ jr z,AddNewEnd ;For
- dec a \ jr nz,SearchEndLoop ;End
- djnz SearchEndLoop
- inc hl
- ret
- AddNewEnd:
- inc b
- jr SearchEndLoop
- ;===============================================================
- GetGrammerText:
- ;===============================================================
- ;Input:
- ; HL points to the start of the string
- ;Outputs:
- ; A is the value of the ending byte of the string
- ; BC is the size of the string
- ; DE points to the start of the converted string
- ; HL points to the ending byte of the string
- ; z flag is set
- ;===============================================================
- ld bc,0 ;010000
- ld de,86ECh ;11EC86
- push de
- TextConvert:
- ld a,(hl) ;7E
- cp 4
- jr z,TextConvertEnd
- cp 3Fh
- jr z,TextConvertEnd
- cp 2Ah
- jr z,TextConvertEnd
- push hl
- push bc
- push de
- bcall(4594h)
- pop de
- pop hl
- add hl,bc
- push hl
- ld hl,848Eh
- ldir
- pop bc
- pop hl
- ld a,(hl) ;7E
- call Is_2_Byte
- jr nz,$+3
- inc hl
- inc hl
- cp 2Ah
- jr nz,TextConvert ;FE2A20F3
- TextConvertEnd:
- inc hl
- pop de
- ret
- ;===============================================================
- GetGrammerStr:
- ;===============================================================
- ;Input:
- ; HL points to the start of the string
- ;Outputs:
- ; A is the value of the ending byte of the string
- ; BC is the size of the string
- ; DE is (progEnd)
- ; HL points to the ending byte of the string
- ; z flag is set
- ;===============================================================
- ld bc,0 ;010000
- inc hl ;23
- inc bc ;03
- ld a,(hl) ;7E
- cp 4 \ ret z ;FE04C8
- cp 3Fh \ ret z ;FE3FC8
- cp 2Ah \ jr nz,$-11 ;FE2A20F3
- inc hl ;23
- ret ;C9
- ;===============================================================
- VarPointer:
- ;===============================================================
- ;Inputs:
- ; A is the var to return the pointer of
- ; hl points to the next byte
- ;Outputs:
- ; A is the lower 8-bits of the pointer
- ; BC is not affected
- ; DE should be used to update (progPtr)
- ; HL points to the var data
- ; c flag is reset if A was not a var token
- cp 41h ;FE41
- ccf \ ret nc ;3FD0
- cp 5Ch ;FE5C
- ret nc ;D0
- sub 41h ;D641
- rlca ;07
- ld d,90h ;1680
- ld e,a ;5F
- ld a,(hl) ;7E
- cp $AE ;FEAE ' token
- jr nz,$+6 ;2005
- ld a,36h ;3E36
- add a,e ;83
- ld e,a ;5F
- inc hl ;23
- ld a,e ;7B
- add a,D3h ;C6D3
- jr nc,$+3 ;3001
- inc d ;14
- ld e,a ;5F
- ex de,hl ;EB
- scf ;37
- ret ;C9
- ;===============================================================
- EndOfLine:
- ;===============================================================
- ;Input:
- ; HL is a pointer
- ;Output:
- ; HL points to the next line
- ; DE is (progEnd)
- ;===============================================================
- ld a,3Fh ;3E3F
- push bc
- ld bc,0
- cpir ;
- pop bc
- ret ;C9
- ;===============================================================
- EndOfNumber:
- ;===============================================================
- ;Input:
- ; HL points to a string of numbers or the byte before it
- ;Outputs:
- ; a is the ending non-number byte
- ; hl points to the end of the number
- ; DE is (progEnd)
- ; c flag is set if a<30h or reset if c>39h
- ;===============================================================
- inc hl ;23
- ld a,(hl) ;7E
- call IsHLAtEOF ;CD****
- ret nc ;D0
- cp 30h ;FE30
- ret c ;D8
- cp 3Ah ;FE3A
- jr c,EndOfNumber ;38F7
- ret ;C9
- ;===============================================================
- EndOfHexNum:
- ;===============================================================
- ;Inputs:
- ;Outputs:
- ;===============================================================
- inc hl ;23
- ld a,(hl) ;7E
- call IsHLAtEOF ;CD****
- ret nc ;D0
- cp 30h ;FE30
- ret c ;D8
- cp 3Ah ;FE3A
- jr c,EndOfHexNum ;38F7
- cp 41h ;FE30
- ret c ;D8
- cp 47h ;FE3A
- jr c,EndOfHexNum ;38F0
- ret ;C8
- ;===============================================================
- IsHexTok:
- ;===============================================================
- ;Input:
- ; DE points to the byte after the byte to check
- ;Output:
- ; DE is decremented by 1
- ; A is the hex value if A is a hex token
- ; nc if A is a hex token
- ; c if A is not a hex token
- ;===============================================================
- ld a,(de)
- inc de
- cp 47h
- ccf \ ret c
- cp 40h
- jr nc,$+8
- cp 3Ah
- ccf \ ret c
- jr $+4
- sub 7
- sub 30h
- ret
- ;===============================================================
- ConvRStr:
- ;===============================================================
- ;Input:
- ; HL points to the number or the byte before the number
- ;Outputs:
- ; A is the byte before the number
- ; BC is the 16-bit value of the number
- ; DE is 10^(number of digits plus one)
- ; HL points to the byte after the number
- ;===============================================================
- ; jr $
- dec hl
- bit 3,(iy+34)
- jp nz,ConvHexStr
- call EndOfNumber ;CD****
- push hl ;E5
- ld de,0 ;110000
- ld (TempWord1),de ;ED537C98
- inc e ;1C
- call ConvLoop
- jr nc,ConvComplete
- ld de,10
- call ConvLoop
- jr nc,ConvComplete
- ld de,100
- call ConvLoop
- jr nc,ConvComplete
- ld de,1000
- call ConvLoop
- jr nc,ConvComplete
- ld de,10000
- call ConvLoop
- ConvComplete:
- ld bc,(TempWord1) ;ED4B7C98
- pop hl ;E1
- ret ;C9
- ConvLoop:
- dec hl
- ld a,(hl) ;7E
- sub 30h ;FE30
- ccf \ ret nc
- cp 10 ;FE3A
- ret nc
- push hl ;E5
- rlca \ rlca
- rlca \ rlca
- ld hl,0 ;faster than sbc hl,hl
- ld b,4 ;0604 7 7
- add hl,hl ;29 11*4 44
- rlca ;07 4*4 16
- jr nc,$+3 \ add hl,de ;300119 (12|18)*4 48+6x
- djnz $-5 ;10F9 13*3+8 47
- ld bc,(TempWord1) ;ED4B7C98
- add hl,bc ;09
- ld (TempWord1),hl ;227C98
- pop hl ;E1
- scf
- ret
- ;===============================================================
- HL_Times_BC:
- ;===============================================================
- ;Inputs:
- ; DE and BC are factors
- ;Outputs:
- ; DEHL is the 32-bit value of the product
- ; BC is unchanged
- ; A is 0
- ;===============================================================
- ex de,hl ;EB
- ;===============================================================
- DE_Times_BC:
- ;===============================================================
- ;Inputs:
- ; DE and BC are factors
- ;Outputs:
- ; DEHL is the 32-bit value of the product
- ; BC is unchanged
- ; A is 0
- ;Speed: Max: 1205 cycles
- ; Min: 902 cycles
- ; Avg: 1046 cycles
- ;===============================================================
- ; Mnemonic ;size hex cycles Total
- ;===============================================================
- ld hl,0 ;3 21000 10 10
- ld a,16 ;2 3E10 7 7
- MultLoop:
- add hl,hl ;1 29 11 176
- rl e \ rl d ;4 CB13CB12 16 256
- jr nc,$+6 ;6 300109300113 12|30|31 192|480|496
- add hl,bc ;
- jr nc,$+3 ;
- inc de ;
- dec a ;1 3D 4 64
- jr nz,MultLoop ;2 20** 7+12*15 187
- ret ;1 C9 10 10
- ;===============================================================
- DE_Div_BC:
- ;===============================================================
- ;Performs DE/BC
- ;Speed: 1498 cycles
- ;Size: 24 bytes
- ;Inputs:
- ; DE is the numerator
- ; BC is the denominator
- ;Outputs:
- ; HL is the quotient
- ; DE is the remainder
- ; BC is not changed
- ; A is 0
- ; z flag is set
- ; c flag is reset
- ;===============================================================
- ex de,hl ;EB
- ;===============================================================
- HL_Div_BC:
- ;===============================================================
- ;Performs HL/BC
- ;Speed: 1494 cycles
- ;Size: 23 bytes
- ;Inputs:
- ; HL is the numerator
- ; BC is the denominator
- ;Outputs:
- ; HL is the quotient
- ; DE is the remainder
- ; BC is not changed
- ; A is 0
- ; z flag is set
- ; c flag is reset
- ;===============================================================
- ld a,16 ;3E10 7 7
- ld de,0 ;110000 10 10
- Div16Loop:
- add hl,hl ;29 11 176
- ex de,hl ;EB 4 64
- adc hl,hl ;ED6A 15 240
- or a ;B7 4 64
- sbc hl,bc ;ED42 15 240
- jr c,$+5 ;3803 23|23 368 (I feel special ^^)
- inc e ;1C --
- jr EndDiv16Loop ;1801 --
- add hl,bc ;09 --
- EndDiv16Loop:
- ex de,hl ;EB 4 64
- dec a ;3D 4 64
- jr nz,Div16Loop ;20EF 7+15*12 187
- ret ;C9 10 10
- ;===============================================================
- HL_Times_A:
- ;===============================================================
- ;Speed: 346+6x cycles where x is the number of set bits in "a"
- ;Size: 14 bytes
- ;Inputs:
- ; HL and A are factors
- ;Outputs:
- ; A is unchanged
- ; B is 0
- ; C is unchanged
- ; DE is the original HL value
- ; HL is the product
- ;===============================================================
- ex de,hl ;EB
- ;===============================================================
- DE_Times_A:
- ;===============================================================
- ;Speed: 342+6x cycles where x is the number of set bits in "a"
- ;Size: 13 bytes
- ;Inputs:
- ; DE and A are factors
- ;Outputs:
- ; A is unchanged
- ; B is 0
- ; C is unchanged
- ; DE is unchanged
- ; HL is the product
- ;=====================================Cycles====================
- ld b,8 ;0608 7 7
- ld hl,0 ;210000 10 10
- add hl,hl ;29 11*8 88
- rlca ;07 4*8 32
- jr nc,$+3 \ add hl,de ;300119 (12|18)*8 96+6x
- djnz $-5 ;10F9 13*7+8 99
- ret ;C9 10 10
- ;===============================================================
- IsHLAtEOF:
- ;===============================================================
- ;Input:
- ; HL is an address
- ;Outputs:
- ; de is (progEnd)
- ; c flag is set if HL is not at or past the end of the code
- ; nc if hl is at or past the end of the code
- ;===============================================================
- ld de,(progEnd) ;ED5B7498
- or a ;B7
- sbc hl,de ;ED52
- add hl,de ;19
- ret ;C9
- ;===============================================================
- SearchString:
- ;===============================================================
- ;Inputs:
- ; BC-size o' string
- ; DE-points to search string
- ; HL-start of search
- ; (progEnd) contains the end of the file
- ;Outputs:
- ; c flag set if there was a match, nc if no match was found
- ; HL points to the match if there was one
- ; DE is not changed
- ; BC is not changed
- ;Destroys:
- ; A
- ;===============================================================
- ld (TempWord1),bc
- ld (TempWord2),de
- SearchStringLoop:
- ld de,(TempWord2)
- ld bc,(TempWord1)
- ; push de
- ; call IsHLAtEOF
- ; pop de
- ; ret nc
- ld a,(de) ;1A
- inc de ;13
- cpi ;EDA1
- jr nz,SearchStringLoop
- jp po,MatchedString
- jr SearchStringLoop+8
- MatchedString:
- ld bc,(TempWord1)
- ld de,(TempWord2)
- scf ;37
- ret ;C9
- ;===============================================================
- CheckStatus:
- ;===============================================================
- ;Speed: 89 cycles
- ;Size: 13 bytes
- ;Outputs:
- ; z is set if ON is being pressed
- ; c is set if 15MHz mode is used
- ;===============================================================
- push bc ;C5 11
- push af ;F5 11
- in a,(4) ;DB04 11
- and 8 ;E608 7 Check [on]
- in a,(20) ;DB20 11
- rra ;1F 4 c if 15MHz
- pop bc ;C1 10
- ld a,b ;78 4
- pop bc ;C1 10
- ret ;C9 10
- ;===============================================================
- GraphToLCD:
- ;===============================================================
- ld hl,(BufPtr) ;214093
- ;===============================================================
- BufferToLCD:
- ;===============================================================
- ;Input:
- ; HL points to the buffer to copy to the LCD
- ;Outputs:
- ;
- ;===============================================================
- ld c,17 ;0E11
- ld d,64 ;1640
- LCDDelay()
- ld a,7 ;3E07 7 27
- out (16),a ;D310
- LCDLoop:
- nop ;00 4
- LCDDelay()
- ld a,32 ;3E20 7 127
- out (16),a ;D310
- LCDDelay()
- ld a,$C0 ;3EC0 7
- sub d ;92 4 127
- out (16),a ;D310
- ld b,12 ;060C
- LCDWriteLoop:
- ld a,(hl) \ inc hl
- bit 1,(iy+34)
- jr z,$+3
- cpl
- ld c,a
- LCDDelay()
- ld a,c
- out (17),a
- djnz LCDWriteLoop ;20F6
- dec d ;15
- jr nz,LCDLoop ;20DC
- LCDDelay()
- ld a,5 ;3E05 7 132
- out (16),a ;D310
- ret ;C9
- ;===============================================================
- DrawRectToGraph:
- ;===============================================================
- ;Inputs:
- ; A is the type of rectangle to draw
- ; 0 =White
- ; 1 =Black
- ; 2 =XOR
- ; 3 =Black border
- ; 4 =White border
- ; 5 =XOR border
- ; 6 =Black border, white inside
- ; 7 =Black border, XOR inside
- ; 8 =White border, black inside
- ; 9 =White border, XOR inside
- ; 10=Shift Up
- ; 11=Shift Down
- ; B is the height
- ; C is the Y pixel coordinate
- ; D is the width in pixels
- ; E is is the X pixel coordinate
- ;===============================================================
- call MakeRectPatternBatLib
- .db $CB,$67,$28,$10,$D6,$10,$F5,$0E,$18,$11,$EC,$86,$1A,$2F,$12,$13,$0D,$20,$F9,$F1,$B7,$20,$11,$0E
- .db $0C,$11,$EC,$86,$1A,$2F,$A6,$77,$13,$23,$0D,$20,$F7,$10,$F0,$C9,$3D,$20,$10,$0E,$0C,$11,$EC,$86
- .db $1A,$B6,$77,$13,$23,$0D,$20,$F8,$10,$F1,$C9,$3D,$20,$10,$0E,$0C,$11,$EC,$86,$1A,$AE,$77,$13,$23
- .db $0D,$20,$F8,$10,$F1,$C9,$3D,$20,$24,$0E,$0C,$11,$EC,$86,$1A,$B6,$77,$13,$23,$0D,$20,$F8,$05,$C8
- .db $05,$28,$0F,$0E,$0C,$11,$F8,$86,$1A,$B6,$77,$13,$23,$0D,$20,$F8,$10,$F1,$04,$18,$DC,$3D,$20,$26
- .db $0E,$0C,$11,$EC,$86,$1A,$A6,$AE,$77,$13,$23,$0D,$20,$F7,$05,$C8,$05,$28,$10,$0E,$0C,$11,$F8,$86
- .db $1A,$A6,$AE,$77,$13,$23,$0D,$20,$F7,$10,$F0,$04,$18,$DA,$3D,$20,$24,$0E,$0C,$11,$EC,$86,$1A,$AE
- .db $77,$13,$23,$0D,$20,$F8,$05,$C8,$05,$28,$0F,$0E,$0C,$11,$F8,$86,$1A,$AE,$77,$13,$23,$0D,$20,$F8
- .db $10,$F1,$04,$18,$DC,$3D,$20,$34,$0E,$0C,$11,$EC,$86,$1A,$B6,$77,$13,$23,$0D,$20,$F8,$05,$C8,$05
- .db $28,$1F,$E5,$0E,$0C,$11,$EC,$86,$1A,$A6,$AE,$77,$13,$23,$0D,$20,$F7,$E1,$0E,$0C,$11,$F8,$86,$1A
- .db $B6,$77,$13,$23,$0D,$20,$F8,$10,$E1,$04,$18,$CC,$3D,$20,$33,$0E,$0C,$11,$EC,$86,$1A,$B6,$77,$13
- .db $23,$0D,$20,$F8,$05,$C8,$05,$28,$1E,$E5,$0E,$0C,$11,$EC,$86,$1A,$AE,$77,$13,$23,$0D,$20,$F8,$E1
- .db $0E,$0C,$11,$F8,$86,$1A,$B6,$77,$13,$23,$0D,$20,$F8,$10,$E2,$04,$18,$CD,$3D,$20,$34,$0E,$0C,$11
- .db $EC,$86,$1A,$A6,$AE,$77,$13,$23,$0D,$20,$F7,$05,$C8,$05,$28,$1E,$E5,$0E,$0C,$11,$EC,$86,$1A,$B6
- .db $77,$13,$23,$0D,$20,$F8,$E1,$0E,$0C,$11,$F8,$86,$1A,$AE,$77,$13,$23,$0D,$20,$F8,$10,$E2,$04,$18
- .db $CC,$3D,$20,$35,$0E,$0C,$11,$EC,$86,$1A,$A6,$AE,$77,$13,$23,$0D,$20,$F7,$05,$C8,$05,$28,$1F,$E5
- .db $0E,$0C,$11,$EC,$86,$1A,$AE,$77,$13,$23,$0D,$20,$F8,$E1,$0E,$0C,$11,$F8,$86,$1A,$A6,$AE,$77,$13
- .db $23,$0D,$20,$F7,$10,$E1,$04,$18,$CB,$3D,$20,$37,$05,$C8,$F3,$E5,$D9,$01,$0C,$00,$E1,$09,$D9,$0E
- .db $0C,$11,$EC,$86,$D5,$D9,$D1,$D9,$1A,$2F,$A6,$D9,$47,$1A,$A6,$B0,$13,$23,$D9,$77,$13,$23,$0D,$20
- .db $EF,$10,$E4,$0E,$0C,$11,$EC,$86,$1A,$2F,$A6,$77,$13,$23,$0D,$20,$F7,$FB,$C9,$3D,$20,$40,$F3,$C5
- .db $11,$0C,$00,$19,$10,$FD,$2B,$E5,$D9,$11,$F4,$FF,$E1,$19,$D9,$C1,$05,$C8,$0E,$0C,$11,$F7,$86,$D5
- .db $D9,$D1,$D9,$1A,$2F,$A6,$D9,$47,$1A,$A6,$B0,$1B,$2B,$D9,$77,$1B,$2B,$0D,$20,$EF,$10,$E4,$0E,$0C
- .db $11,$F7,$86,$1A,$2F,$A6,$77,$1B,$2B,$0D,$20,$F7,$FB,$C9,$3D,$20,$03,$11,$F4,$FF,$19,$0E,$0C,$11
- .db $17,$00,$19,$11,$F7,$86,$AF,$F5,$EB,$F1,$1A,$17,$F5,$A6,$F5,$EB,$1A,$2F,$A6,$77,$F1,$B6,$EB,$12
- .db $1B,$2B,$0D,$20,$EC,$F1,$EB,$10,$DC,$C9,$EB,$0E,$0C,$21,$EC,$86,$AF,$F5,$F1,$1A,$1F,$F5,$A6,$F5
- .db $7E,$2F,$EB,$A6,$77,$F1,$B6,$77,$EB,$13,$23,$0D,$20,$EC,$F1,$10,$E2,$C9
- ;========================================================
- MakeRectPatternBatLib:
- ;========================================================
- .db $F5,$C5,$06,$00,$C5,$D5,$D5,$21,$EC,$86,$36,$00,$11,$ED,$86,$01,$18,$00,$ED,$B0,$D1,$7B,$0F,$0F
- .db $0F,$E6,$0F,$26,$00,$6F,$7B,$E6,$07,$F5,$47,$3E,$FF,$28,$04,$CB,$3F,$10,$FC,$11,$EC,$86,$19,$77
- .db $F1,$2F,$E6,$07,$3C,$47,$F1,$90,$CB,$7F,$28,$0F,$E6,$07,$B7,$28,$06,$47,$AF,$37,$1F,$10,$FC,$A6
- .db $77,$18,$15,$23,$FE,$08,$38,$06,$36,$FF,$D6,$08,$18,$F5,$B7,$28,$06,$47,$AF,$37,$1F,$10,$FC,$77
- .db $E1,$29,$29,$44,$4D,$29,$09,$ED,$4B
- .dw BufPtr
- .db $09,$E5,$D5,$21,$EB,$86,$11,$F7,$86,$13,$23,$7E,$B7,$28,$FA,$CB,$3F,$AE,$12,$23,$7E,$2B,$B7,$20
- .db $09,$7E,$CB,$3F,$86,$2F,$A6,$12,$18,$11,$13,$23,$7D,$FE,$F8,$28,$04,$7E,$B7,$20,$F5,$1B,$2B,$7E
- .db $87,$AE,$12,$D1,$E1,$C1,$F1,$C9
- ;===============================================================
- DrawRectToGraphOopsThisLabelIsWrong:
- ;===============================================================
- ; a is the method to draw with
- ; b is the height
- ; c is the width
- ; d is the x coordinate
- ; e is the y coordinate
- ; hl points to the buffer to draw to
- ;===============================================================
- ld hl,(BufPtr) ;214093
- call FormRectPattern
- jp DrawRectPattern
- ;===============================================================
- FormRectPattern:
- ;===============================================================
- ;Outputs:
- ; A is the drawing method
- ; HL points to the buffer location for the sprite
- ; C is the height
- ; B is the byte width
- ;===============================================================
- dec c
- push af
- push bc
- push hl
- ld a,d
- ld d,0
- ld h,d
- ld l,e
- add hl,de
- add hl,de
- add hl,hl
- add hl,hl
- ld d,a
- and 78h
- rrca \ rrca \ rrca
- ld e,a
- ld a,d
- ld d,0
- add hl,de
- pop de
- add hl,de
- push hl
- and 7
- ld hl,86ECh
- call RectPattern
- ld b,c
- pop hl
- pop af
- ld c,a
- pop af
- ld d,a ;57
- ld a,c ;79
- di ;F3
- ex af,af' ;08
- ld a,12 ;3E0C
- sub b ;90
- jr nc,zzrs
- exx
- ld hl,86F9h
- ld de,86F8h
- ld bc,12
- ldir
- exx
- xor a
- ld b,12
- zzrs:
- ld c,a ;4F
- ld a,d ;7A
- ret
- ;=======================================================
- DrawRectPattern:
- ;=======================================================
- ld de,86ECh
- or a ;B7
- jr nz,tirit1
- EraseBxA:
- ex af,af'
- ex af,af'
- push de
- push bc
- ld a,(de)
- cpl
- and (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-6
- add hl,bc
- pop bc
- pop de
- ex af,af'
- dec a
- jr nz,EraseBxA+1
- ret
- tirit1:
- dec a ;3D
- jr nz,tirit2
- ORBxA:
- ex af,af'
- ex af,af'
- push de
- push bc
- ld a,(de)
- or (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-5
- add hl,bc
- pop bc
- pop de
- ex af,af'
- dec a
- jr nz,ORBxA+1
- ret
- tirit2:
- dec a ;3D
- jr nz,tirit3
- XORBxA:
- ex af,af'
- ex af,af'
- push de
- push bc
- ld a,(de)
- xor (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-5
- add hl,bc
- pop bc
- pop de
- ex af,af'
- dec a
- jr nz,XORBxA+1
- ret
- tirit3:
- dec a ;3D
- jr nz,tirit4 ;20** black border
- push de
- call ORBx1
- call ORBxA
- pop de
- ORBx1:
- push bc
- ld a,(de)
- or (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-5
- add hl,bc
- pop bc
- ex af,af'
- dec a
- dec a
- ex af,af'
- ret
- tirit4:
- dec a ;3D
- jr nz,tirit5 ;20** White Border
- push de
- call EraseBx1
- call EraseBxA
- pop de
- EraseBx1:
- push bc
- ld a,(de)
- cpl
- and (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-6
- add hl,bc
- pop bc
- ex af,af'
- dec a
- dec a
- ex af,af'
- ret
- tirit5:
- dec a ;3D
- jr nz,tirit6 ;20** XOR Border
- push de
- call XORBx1
- call XORBxA
- pop de
- XORBx1:
- push bc
- ld a,(de)
- xor (hl)
- ld (hl),a
- inc de
- inc hl
- djnz $-5
- add hl,bc
- pop bc
- ex af,af'
- dec a
- dec a
- ex af,af'
- ret
- tirit6:
- dec a ;3D
- jr nz,tirit7 ;20** BbWi
- call ORBx1
- push de
- ld de,86ECh
- push hl
- ex af,af'
- push af
- call EraseBxA+1
- pop af
- pop hl
- pop de
- call ORBxA+1
- ld de,86ECh
- jp ORBx1
- tirit7:
- dec a ;3D
- jr nz,tirit8 ;20** BbXi
- call ORBx1
- push de
- ld de,86ECh
- push hl
- ex af,af'
- push af
- call XORBxA+1
- pop af
- pop hl
- pop de
- call ORBxA+1
- ld de,86ECh
- jp ORBx1
- tirit8:
- dec a ;3D
- jr nz,tirit9 ;20** WbBi
- call EraseBx1
- push de
- ld de,86ECh
- push hl
- ex af,af'
- push af
- call ORBxA+1
- pop af
- pop hl
- pop de
- call EraseBxA+1
- ld de,86ECh
- jp EraseBx1
- tirit9:
- dec a ;3D
- jr nz,tiritA ;20** WbXi
- call EraseBx1
- push de
- ld de,86ECh
- push hl
- ex af,af'
- push af
- call XORBxA+1
- pop af
- pop hl
- pop de
- call EraseBxA+1
- ld de,86ECh
- jp EraseBx1
- tiritA:
- ; dec a ;3D
- ; jr nz,tiritB ;20**
- tiritB:
- ; dec a ;3D
- ; jr nz,tiritC ;20**
- tiritC:
- ; dec a ;3D
- ; jr nz,tiritD ;20**
- tiritD:
- ; dec a ;3D
- ; jr nz,tiritE ;20**
- tiritE:
- ; dec a ;3D
- ; jr nz,tiritF ;20**
- tiritF:
- ret
- ;===============================================================
- RectPattern
- ;===============================================================
- ;Inputs:
- ; c is the width in pixels (good up to 127)
- ; a is the number of bits to shift to the right
- ; hl points to where to draw the pattern
- ;Outputs:
- ; b is 0
- ; c is the number of bytes wide the pattern is
- ; e is 0
- ; hl points to the byte after the shifted data
- ;Destroys:
- ; a,d
- ;===============================================================
- push af ;F1
- ld a,c ;79
- and 78h ;E678
- rrca \ rrca ;0F0F
- inc a ;3C
- inc a ;3C
- ld b,a ;4F
- inc b ;04
- inc b ;04
- ld (hl),0 ;3600
- inc hl ;23
- djnz $-3 ;10FB
- rrca ;0F
- ld b,a ;47
- ld a,c ;79
- ld c,b ;48
- and 7 ;E607
- ld b,a ;47
- ld a,80h ;3E80
- rrca ;0F
- djnz $-1 ;10FD
- dec hl ;2B
- dec hl ;2B
- ld b,a ;47
- or (hl) ;B6
- ld (hl),a ;77
- ld a,l ;7D
- inc a ;3C
- sub c ;91
- jr nc,$+3 ;3001
- dec h ;25
- ld l,a ;6F
- set 7,(hl) ;CBFE
- ld a,b ;78
- dec a ;3D
- dec hl ;2B
- dec hl ;2B
- ld (hl),a ;77
- ld b,c ;41
- ld a,255 ;3EFF
- xor (hl) ;AE
- ld (hl),a ;77
- dec hl ;2B
- djnz $-5 ;10F9
- inc c ;0C
- inc hl ;23
- ld d,2 ;1602
- pop af ;F1
- ;===============================================================
- ShiftDataRightX:
- ;===============================================================
- ;Inputs:
- ; a is the number of shifts (uses first 3 bits)
- ; d is the number of lines
- ; c is the number of bytes per line
- ; hl points to the data
- ;Outputs:
- ; b is 0
- ; e is 0
- ; c is not changed
- ; hl points to the byte after the shifted data
- ; The data is shifted up to 7 bits right
- ;Destroys:
- ; a,d
- ;===============================================================
- rrca ;0F
- push hl ;E5
- call c,ShiftDataRight ;
- pop hl ;E1
- rrca ;0F
- push hl ;E5
- call c,ShiftDataRight ;
- pop hl ;E1
- rlca ;07
- rrca ;0F
- push hl ;E5
- call c,ShiftDataRight ;
- pop hl ;E1
- rrca ;0F
- jr nc,EndSDR4 ;30**
- ShiftDataRight4:
- ld b,d ;42
- ld e,a ;5F
- ld d,c ;51
- xor a ;AF
- rrd ;ED67
- inc hl ;23
- dec d ;15
- jr nz,$-4 ;20FA
- djnz $-8 ;10F6
- ld a,e ;7B
- EndSDR4:
- ret ;C9
- ShiftDataRight:
- ld b,d ;42
- ld e,c ;59
- or a ;B7
- rr (hl) ;CB1E
- inc hl ;23
- dec e ;1D
- jr nz,$-4 ;20FA
- djnz $-8 ;10F6
- ret ;C9
- PutSS:
- ld d,a \ jr GPutS+2
- GPutSS:
- ld (textRow),bc
- ;===============================================================
- GPutS:
- ;===============================================================
- ;Inputs:
- ; HL points to a zero terminated string to display
- ; (textRow) is the pixel row to draw at
- ; (textCol) is the text column to draw at (0 to 23)
- ;Outputs:
- ; HL points to the ending byte
- ; BC is the size of the string
- ; A is 0
- ; z flag is set
- ; c flag reset
- ;Destroys:
- ; DE
- ;===============================================================
- ld d,0
- ld bc,0
- ld a,(hl) \ cp d \ ret z
- push de
- inc bc \ push bc
- inc hl
- push hl
- call PutSC
- pop hl
- pop bc
- pop de
- jr GPutS+5
- ;===============================================================
- PutSC:
- ;===============================================================
- ;Inputs:
- ; a is the char to draw
- ; (textRow) is the pixel row to draw at
- ; (textCol) is the text column to draw at (0 to 23)
- ;===============================================================
- bit 5,(iy+34)
- jp nz,VPutC
- push af
- ld bc,(textRow)
- ld a,b
- cp 24
- ld a,c
- jr c,$+6
- ld b,0
- add a,6
- cp 3Bh
- jr c,$+8
- sub 3Ch
- jr nc,$+4
- add a,6
- ld c,a
- inc b
- ld (textRow),bc
- dec b
- ld hl,(FontPointer)
- pop af
- ;===============================================================
- PutFS:
- ;===============================================================
- push bc
- push hl
- ld b,0
- ld c,a
- ld h,b
- ld l,c
- add hl,hl
- add hl,bc
- pop de
- add hl,de
- pop bc
- push hl
- ld a,b
- ld b,0
- ld h,b
- ld l,c
- add hl,hl
- add hl,bc
- add hl,hl
- add hl,hl
- rra
- push af
- ld c,a
- add hl,bc
- ld bc,(BufPtr)
- add hl,bc
- ld bc,060Ch
- ;==========================================
- ;Added in for slow text
- bit 0,(iy+33)
- jr z,SkipSlow
- push bc \ push hl
- call GraphToLCD
- pop hl \ pop bc
- ld a,(TextPauseTime)
- bit 1,(iy+33)
- jr nz,$+3
- ei
- halt \ dec a
- jr nz,$-2
- di
- SkipSlow:
- ;==========================================
- pop af
- pop de
- jr c,PutRight
- ;===============================================================
- PutLeft:
- ;===============================================================
- ld a,(hl)
- and 0Fh
- ld (hl),a
- ld a,(de)
- bit 0,(iy+34)
- jr z,$+3
- cpl
- bit 0,b
- jr z,$+7
- rlca \ rlca \ rlca \ rlca
- inc de
- and $F0
- or (hl)
- ld (hl),a
- ld a,b
- ld b,0
- add hl,bc
- ld b,a
- djnz PutLeft
- ret
- ;===============================================================
- PutRight:
- ;===============================================================
- ld a,(hl)
- and $F0
- ld (hl),a
- ld a,(de)
- bit 0,(iy+34)
- jr z,$+3
- cpl
- bit 0,b
- jr nz,$+7
- rlca \ rlca \ rlca \ rlca
- dec de
- inc de
- and 0Fh
- or (hl)
- ld (hl),a
- ld a,b
- ld b,0
- add hl,bc
- ld b,a
- djnz PutRight
- ret
- ;===============================================================
- SqrtHL:
- ;===============================================================
- di ;1 4 4
- exx ;1 4 4
- xor a ;1 4 4
- ld h,a ;1 4 4
- ld l,a ;1 4 4
- ld b,8 ;2 7 7
- sqrtHLLoop:
- rlca ;1 4 32
- ld d,0 ;2 7 56
- ld e,a ;1 4 32
- ex de,hl ;1 4 32
- add hl,hl ;1 11 88
- inc l ;1 4 32
- ex de,hl ;1 4 32
- exx ;1 4 32
- add hl,hl ;1 11 88
- exx ;1 4 32
- adc hl,hl ;2 15 120
- exx ;1 4 32
- add hl,hl ;1 11 88
- exx ;1 4 32
- adc hl,hl ;2 15 120
- sbc hl,de ;2 15 120
- jr c,$+5 ;5 12|23 96+11x
- inc a ;-- -- --
- jr $+3 ;-- -- --
- add hl,de ;1 11 88
- djnz sqrtHLLoop ;2 13|8 99
- ret ;1 10 10
- ;===============================================================
- FontSet:
- ;===============================================================
- ;00~7F
- .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$8C,$EC,$80,$00,$00,$00,$00,$00,$00
- .db $24,$44,$20,$0A,$4A,$00,$00,$EA,$E0,$00,$4E,$40,$00,$04,$00,$00,$E4,$44,$E4,$2C,$00,$EC,$EC,$C0
- .db $65,$5C,$40,$62,$A2,$00,$C2,$4E,$00,$02,$48,$E0,$69,$96,$00,$AC,$88,$00,$E4,$40,$00,$68,$60,$E0
- .db $2E,$4E,$80,$C2,$C0,$E0,$06,$00,$00,$E8,$C8,$E0,$42,$F2,$40,$AD,$DD,$A0,$4E,$44,$40,$44,$4E,$40
- .db $00,$00,$00,$44,$40,$40,$AA,$A0,$00,$00,$00,$00,$00,$00,$00,$A2,$48,$A0,$4A,$4A,$50,$88,$80,$00
- .db $24,$44,$20,$84,$44,$80,$00,$40,$00,$04,$E4,$00,$00,$44,$80,$00,$E0,$00,$00,$00,$80,$22,$48,$80
- ;FontNumbers
- .db $4A,$AA,$40,$4C,$44,$E0,$C2,$48,$E0,$C2,$42,$C0,$AA,$E2,$20,$E8,$C2,$C0,$68,$EA,$E0,$E2,$44,$40,$EA,$EA,$E0,$EA,$E2,$20
- ;3Ah~3Fh
- .db $04,$04,$00,$04,$04,$80,$24,$84,$20,$0E,$0E,$00,$84,$24,$80,$C2,$40,$40
- .db $00,$00,$00,$4A,$EA,$A0,$CA,$CA,$C0,$68,$88,$60,$CA,$AA,$C0,$E8,$C8,$E0,$E8,$C8,$80,$68,$AA,$60
- .db $AA,$EA,$A0,$E4,$44,$E0,$62,$2A,$40,$AA,$CA,$A0,$88,$88,$E0,$AE,$AA,$A0,$CA,$AA,$A0,$EA,$AA,$E0
- .db $CA,$C8,$80,$EA,$AE,$60,$CA,$CA,$A0,$68,$42,$C0,$E4,$44,$40,$AA,$AA,$E0,$AA,$AA,$40,$AA,$AE,$A0
- .db $AA,$4A,$A0,$AA,$44,$40,$E2,$48,$E0,$4A,$EA,$40,$88,$42,$20,$C4,$44,$C0,$4A,$00,$00,$00,$00,$E0
- .db $84,$00,$00,$06,$AA,$60,$88,$CA,$C0,$06,$88,$60,$22,$6A,$60,$04,$AC,$60,$48,$C8,$80,$06,$A6,$2C
- .db $88,$CA,$A0,$40,$44,$40,$20,$22,$A4,$8A,$CA,$A0,$88,$88,$40,$0A,$EA,$A0,$0C,$AA,$A0,$04,$AA,$40
- .db $0C,$AC,$80,$06,$A6,$22,$0A,$C8,$80,$0C,$84,$C0,$4E,$44,$20,$0A,$AA,$E0,$0A,$AA,$40,$0A,$AE,$A0
- .db $0A,$44,$A0,$0A,$A6,$24,$0E,$24,$E0,$64,$84,$60,$44,$44,$40,$C4,$24,$C0,$05,$A0,$00,$E0,$E0,$E0
- ;FontNumbers2
- .db $04,$AA,$A4,$04,$C4,$4E,$0C,$24,$8E,$0C,$24,$2C,$0A,$AE,$22,$0E,$8C,$2C,$06,$8E,$AE,$0E,$24,$44
- .db $0E,$AE,$AE,$0E,$AE,$22
- ;Accented A
- .db $24,$AE,$A0,$84,$AE,$A0,$00,$00,$00,$A4,$AE,$A0
- ;Accented a
- .db $24,$06,$A5,$42,$06,$A5,$4A,$06,$A5,$A0,$6A,$60
- ;Accented E
- .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
- ;Accented e
- .db $48,$4A,$C6,$42,$4A,$C6,$4A,$4A,$C6,$A0,$4A,$C6
- ;Accented I
- .db $24,$0E,$4E,$84,$0E,$4E,$4A,$0E,$4E,$A0,$E4,$E0
- ;Accented i
- .db $24,$04,$44,$84,$04,$44,$4A,$04,$44,$A0,$44,$40
- ;Bombs... er, accented O
- .db $24,$69,$96,$84,$69,$96,$4A,$69,$96,$A0,$69,$96
- ;Lowercase bombs
- .db $24,$06,$96,$84,$06,$96,$4A,$06,$96,$A0,$06,$96
- ;Accented U
- .db $24,$AA,$A6,$84,$AA,$A6,$4A,$AA,$A6,$A0,$AA,$A6
- ;Accented u
- .db $24,$0A,$A6,$84,$0A,$A6,$4A,$0A,$A6,$A0,$0A,$A6
- ;Accented C,c,N,n
- .db $4A,$8A,$48,$06,$88,$6C,$5A,$0C,$AA,$5A,$0C,$AA
- ;Other Puntuation
- .db $24,$00,$00,$84,$00,$00,$A0,$00,$00,$40,$48,$60
- ;Upside-Down Exclamation Point Identical to lowercase i
- ;Change to something else?
- .db $00,$00,$00
- ;Greek
- .db $05,$AA,$50,$25,$65,$A0,$05,$A2,$20,$00,$4A,$E0,$34,$27,$96,$68,$E8,$60
- ;[
- .db $64,$44,$60
- ;Greek (continued)
- .db $84,$25,$90,$0A,$AD,$80,$0F,$55,$90,$25,$56,$48,$F4,$24,$F0
- .db $07,$55,$40,$07,$A2,$10
- ;Idunno howta do these
- .db $4E,$AE,$40,$69,$99,$69
- ;CC~CF
- .db $E0,$A4,$A0,$E0,$A6,$24,$52,$50,$00,$00,$00,$A0,$26,$E6,$20
- ;D0~D5
- .db $44,$40,$00,$22,$48,$80,$00,$60,$00,$C4,$8C,$00,$EA,$E0,$00,$E4,$2C,$00
- ;D6
- .db $00,$00,$00
- ;D7~DF
- .db $40,$44,$20,$04,$CA,$C8,$8A,$4A,$20,$E9,$AE,$A8,$69,$E8,$60,$00,$44,$60,$9D,$FB,$90,$A5,$55,$A0,$4E,$FE,$40
- ;Overwrite Cursor
- .db $FF,$FF,$FF,$FB,$1B,$BF,$FB,$51,$5F,$FF,$95,$9F
- ;Insert Cursor
- .db $00,$00,$0F,$4E,$EE,$0F,$4A,$EA,$0F,$06,$A6,$0F
- ;E8~EF
- .db $00,$84,$20,$00,$C6,$20,$00,$E6,$20,$00,$8C,$E0,$25,$D5,$20,$4A,$AA,$40,$4E,$44,$40
- ;F0~F4
- .db $44,$4E,$40,$5A,$5A,$5A,$27,$A6,$3E,$4E,$44,$00,$69,$A9,$A0
- ;male/female
- .db $73,$5E,$AE,$EA,$E4,$E4
- ;BlockEater Down $F7
- .db $6F,$96,$90
- ;BlockEater Left $F8
- .db $6F,$16,$90
- ;BlockEater Right $F9
- .db $6F,$86,$90
- ;BlockEater Up $FA
- .db $69,$96,$90
- ;FB~FE
- .db $09,$AC,$E0,$08,$53,$70,$EC,$A1,$00,$73,$58,$00
- ;FF
- .db $A5,$A5,$A5
- ;===============================================================
- vFont:
- ;===============================================================
- .db $01,$00,$80,$01,$00,$00,$01,$00,$00,$01,$00,$00,$04,$05,$00,$00,$00,$00,$01,$00,$00,$01,$00,$00
- .db $08,$03,$40,$80,$80,$80,$80,$80,$40,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$01,$00,$00,$08,$06,$00,$10,$F8,$20,$F8,$40,$00,$00,$01,$00,$00,$08,$04,$00,$00
- .db $00,$E0,$00,$00,$00,$00,$01,$00,$00,$08,$06,$00,$20,$10,$F8,$10,$20,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$08,$05,$00,$00,$00,$00,$00,$00,$00,$00,$08,$03,$40,$40,$40,$40,$40,$00,$40,$00
- .db $08,$05,$50,$50,$50,$00,$00,$00,$00,$00,$01,$00,$00,$01,$00,$00,$08,$04,$A0,$20,$20,$40,$80,$80
- .db $A0,$00,$01,$00,$00,$08,$02,$00,$80,$80,$80,$00,$00,$00,$00,$08,$03,$40,$80,$80,$80,$80,$80,$40
- .db $00,$08,$03,$80,$40,$40,$40,$40,$40,$80,$00,$01,$00,$00,$01,$00,$00,$08,$03,$00,$00,$00,$00,$00
- .db $40,$40,$80,$08,$05,$00,$00,$00,$00,$F0,$00,$00,$00,$08,$02,$00,$00,$00,$00,$00,$00,$80,$00,$08
- .db $04,$20,$20,$20,$40,$80,$80,$80,$00,$08,$06,$70,$88,$98,$A8,$C8,$88,$70,$00,$08,$04,$40,$C0,$40
- .db $40,$40,$40,$E0,$00,$08,$05,$60,$90,$10,$20,$40,$80,$F0,$00,$08,$05,$60,$90,$10,$20,$10,$90,$60
- .db $00,$08,$06,$10,$30,$50,$90,$F8,$10,$10,$00,$08,$05,$F0,$80,$E0,$10,$10,$90,$60,$00,$08,$05,$30
- .db $40,$80,$E0,$90,$90,$60,$00,$08,$05,$F0,$10,$20,$20,$20,$20,$20,$00,$08,$05,$60,$90,$90,$60,$90
- .db $90,$60,$00,$08,$05,$60,$90,$90,$70,$10,$20,$40,$00,$08,$02,$00,$80,$00,$00,$00,$80,$00,$00,$08
- .db $03,$00,$40,$00,$00,$00,$40,$80,$00,$08,$05,$10,$20,$40,$80,$40,$20,$10,$00,$08,$05,$00,$00,$F0
- .db $00,$F0,$00,$00,$00,$08,$05,$80,$40,$20,$10,$20,$40,$80,$00,$08,$05,$60,$90,$10,$20,$20,$00,$20
- .db $00,$08,$08,$7E,$81,$99,$A5,$9E,$00,$00,$00,$08,$05,$60,$90,$90,$F0,$90,$90,$90,$00,$08,$05,$E0
- .db $90,$90,$E0,$90,$90,$E0,$00,$08,$05,$60,$90,$80,$80,$80,$90,$60,$00,$08,$05,$E0,$90,$90,$90,$90
- .db $90,$E0,$00,$08,$05,$F0,$80,$80,$E0,$80,$80,$F0,$00,$08,$05,$F0,$80,$80,$E0,$80,$80,$80,$00,$08
- .db $05,$60,$90,$80,$80,$B0,$90,$60,$00,$08,$05,$90,$90,$90,$F0,$90,$90,$90,$00,$08,$04,$E0,$40,$40
- .db $40,$40,$40,$E0,$00,$08,$05,$70,$20,$20,$20,$20,$A0,$40,$00,$08,$05,$90,$90,$A0,$C0,$A0,$90,$90
- .db $00,$08,$05,$80,$80,$80,$80,$80,$80,$F0,$00,$08,$06,$88,$D8,$A8,$88,$88,$88,$88,$00,$08,$05,$90
- .db $D0,$D0,$B0,$B0,$90,$90,$00,$08,$05,$60,$90,$90,$90,$90,$90,$60,$00,$08,$05,$E0,$90,$90,$E0,$80
- .db $80,$80,$00,$08,$05,$60,$90,$90,$90,$90,$60,$30,$00,$08,$05,$E0,$90,$90,$E0,$90,$90,$90,$00,$08
- .db $05,$60,$90,$80,$60,$10,$90,$60,$00,$08,$04,$E0,$40,$40,$40,$40,$40,$40,$00,$08,$05,$90,$90,$90
- .db $90,$90,$90,$60,$00,$08,$04,$A0,$A0,$A0,$A0,$A0,$A0,$40,$00,$08,$06,$88,$88,$88,$88,$A8,$A8,$50
- .db $00,$08,$04,$A0,$A0,$A0,$40,$A0,$A0,$A0,$00,$08,$05,$90,$90,$90,$70,$10,$10,$60,$00,$08,$06,$F8
- .db $08,$10,$20,$40,$80,$F8,$00,$08,$05,$60,$D0,$90,$F0,$90,$B0,$60,$00,$08,$04,$80,$80,$80,$40,$20
- .db $20,$20,$00,$08,$03,$C0,$40,$40,$40,$40,$40,$C0,$00,$08,$06,$00,$20,$50,$88,$00,$00,$00,$00,$08
- .db $05,$00,$00,$00,$00,$00,$00,$00,$F0,$08,$03,$80,$40,$00,$00,$00,$00,$00,$00,$08,$05,$00,$00,$60
- .db $A0,$A0,$A0,$50,$00,$08,$05,$80,$80,$80,$E0,$90,$90,$E0,$00,$08,$05,$00,$00,$60,$90,$80,$90,$60
- .db $00,$08,$05,$10,$10,$10,$70,$90,$90,$70,$00,$08,$05,$00,$00,$60,$90,$F0,$80,$60,$00,$08,$05,$00
- .db $60,$90,$80,$C0,$80,$80,$00,$08,$05,$00,$00,$00,$70,$90,$70,$10,$60,$08,$05,$80,$80,$80,$E0,$90
- .db $90,$90,$00,$08,$02,$00,$00,$80,$00,$80,$80,$80,$00,$08,$04,$00,$00,$20,$00,$20,$20,$A0,$40,$08
- .db $04,$00,$80,$80,$A0,$C0,$A0,$A0,$00,$08,$03,$00,$80,$80,$80,$80,$80,$40,$00,$08,$04,$00,$00,$A0
- .db $E0,$A0,$A0,$A0,$00,$08,$05,$00,$00,$A0,$D0,$90,$90,$90,$00,$08,$05,$00,$00,$60,$90,$90,$90,$60
- .db $00,$08,$04,$00,$00,$00,$E0,$90,$E0,$80,$80,$08,$05,$00,$00,$60,$A0,$60,$20,$20,$10,$08,$05,$00
- .db $00,$A0,$D0,$80,$80,$80,$00,$08,$04,$00,$00,$60,$80,$40,$20,$C0,$00,$08,$04,$00,$40,$40,$E0,$40
- .db $40,$20,$00,$08,$05,$00,$00,$90,$90,$90,$90,$60,$00,$08,$04,$00,$00,$A0,$A0,$A0,$A0,$40,$00,$08
- .db $04,$00,$00,$A0,$A0,$A0,$E0,$A0,$00,$08,$04,$00,$00,$A0,$A0,$40,$A0,$A0,$00,$08,$05,$00,$00,$90
- .db $90,$70,$10,$10,$60,$08,$05,$00,$00,$00,$F0,$20,$40,$F0,$00,$08,$04,$20,$40,$40,$80,$40,$40,$20
- .db $00,$08,$02,$80,$80,$80,$80,$80,$80,$80,$00,$08,$04,$80,$40,$40,$20,$40,$40,$80,$00,$08,$05,$50
- .db $A0,$00,$00,$00,$00,$00,$00,$08,$05,$00,$F0,$00,$F0,$00,$F0,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$08
- .db $05,$60,$90,$80,$80,$80,$90,$60,$C0,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00
- .db $01,$00,$00,$08,$05,$40,$00,$40,$40,$80,$90,$60,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$08,$03,$C0,$80,$80,$80,$80,$80,$C0,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01
- .db $00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$08,$04,$20,$20,$20,$40,$80
- .db $80,$80,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$08,$04,$00,$80,$00,$80
- .db $80,$A0,$40,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$01,$00
- .db $00,$01,$00,$00,$08,$05,$50,$A0,$50,$A0,$50,$A0,$50,$00,$01,$00,$00,$01,$00,$00,$01,$00,$00,$08
- .db $09,$00,$0E,$06,$0A,$70,$90,$90,$60,$08,$08,$38,$44,$44,$44,$38,$10,$38,$10,$05,$05,$70,$F8,$88
- .db $70,$88,$05,$05,$70,$F8,$08,$70,$88,$05,$05,$70,$F8,$80,$70,$88,$05,$05,$70,$F8,$F8,$70,$88,$04
- .db $04,$10,$A0,$C0,$E0,$04,$04,$80,$50,$30,$70,$04,$04,$E0,$C0,$A0,$10,$04,$04,$70,$30,$50,$80,$08
- .db $04,$A0,$50,$A0,$50,$A0,$50,$A0,$00,$01,$00,$00,$01,$00,$00
- ;===============================================================
- FastCircle:
- ;===============================================================
- Circle:
- ;===============================================================
- ;Input:
- ; D = center_x
- ; E = center_y
- ; C = radius
- ; A = method
- ;Outputs:
- ;===============================================================
- di
- ld a,c
- or a \ ret z
- ret m
- ld h,c ;h is radius
- ld l,0
- ld a,c
- ld b,-1
- ld (TempWord3),de
- ; jr $
- DrawLoop:
- ex af,af'
- ld a,(TempWord1+1)
- rlca
- ld (TempWord1+1),a
- jr c,$+8
- call Plot4Pix
- call Plot4Pix
- ex af,af'
- inc l
- inc b \ inc b
- sub b
- dec a
- jp p,$+7 ;sign flag reset
- add a,c
- add a,c
- dec h
- inc b
- inc a
- ld d,a
- ld a,h \ sub l
- ld a,d
- jr nc,DrawLoop
- ret
- Plot4Pix:
- ld de,(TempWord3)
- ld a,h \ ld h,l \ ld l,a
- ld a,d \ add a,h \ ld d,a
- ld a,e \ add a,l \ ld e,a
- call PixelSet
- push de
- ld a,d \ sub h \ sub h \ ld d,a
- call PixelSet
- ld a,e \ sub l \ sub l \ ld e,a
- call PixelSet
- pop de
- ld a,e \ sub l \ sub l \ ld e,a
- PixelSet:
- ; DE = (x,y)
- ld a,(TempWord1)
- push de
- exx
- pop bc
- ld d,a
- call PlotPixel
- exx
- ret
- SetMem:
- ld (hl),a
- cpi
- jp pe,SetMem
- ret
- ;=================================================================
- ConvNumBase:
- ;=================================================================
- ;Inputs:
- ; C is the base to convert to
- ; HL is the number to convert
- ;Output:
- ; A is the number of digits
- ; BC is the number of digits
- ; DE is 0
- ; HL points to the number string
- ;Notes:
- ; This converts HL to a zero terminated string stored in OP4
- ; and possibly a few bytes of OP3.
- ;=================================================================
- xor a
- ld de,84A3h
- ld (de),a
- dec de
- call HL_Div_C
- cp 10
- jr c,$+4
- add a,7
- add a,48
- ld (de),a
- dec de
- ld a,h
- or l
- jr nz,$-15
- ld a,$A2
- sub e
- ld c,a
- inc de
- ex de,hl
- ret
- ;=================================================================
- HL_Div_C:
- ;=================================================================
- ;Inputs:
- ; HL is the numerator
- ; C is the denominator
- ;Outputs:
- ; A is the remainder
- ; B is 0
- ; C is not changed
- ; DE is not changed
- ; HL is the quotient
- ;=================================================================
- ld b,16
- xor a
- add hl,hl
- rla
- cp c
- jr c,$+4
- inc l
- sub c
- djnz $-7
- ret
- ;===============================================================
- Is_2_Byte:
- ;===============================================================
- sub $EF \ ret z ;ef
- add a,34h \ ret z ;bb
- add a,3Dh \ ret z ;7E
- Is_Var_Name:
- ;Before calling this, add 82h to a
- sub 2Ch \ ret z ;AA
- add a,47h \ ret z ;63
- inc a \ ret z
- inc a \ ret z
- inc a \ ret z
- add a,2 \ ret z
- inc a \ ret z
- inc a \ ret
- ;===============================================================
- DrawLine:
- ;Inputs:
- ; A is the draw method
- ; 0=PixelOff
- ; 1=PixelOn
- ; 2=PixelChange
- ; BC is (x1,y1)
- ; DE is (y2,x2)
- ;Taken from Axe
- ;d and c are x coordinates
- ;e and b are y logics
- .db 21h \ cpl \ xor c
- or a
- jr nz,$+5
- .db 21h \ or c \ cpl
- dec a
- jr nz,$+5
- .db 21h \ cpl \ or c
- ld (LineTypeVar),hl
- ld l,d
- ld a,d ;?
- ld ix,(BufPtr)
- cp 64
- ret nc
- ld a,e
- cp 64
- ret nc
- ld d,l
- ld l,b
- ld a,d
- cp 96
- ret nc
- ld a,c
- cp 96
- ret nc
- ld h,a
- sub d
- jr nc,__LineSkipRev
- ex de,hl
- neg
- __LineSkipRev:
- push af ; Saving DX (it will be popped into DE below)
- ld a,d ; IX+=D/8+E*12 (actually E*4+E*4+E*4)
- rra
- rra
- rra
- and %00011111
- ld c,a
- ld b,0
- add ix,bc
- ld a,e
- add a,a
- add a,a
- ld c,a
- add ix,bc
- add ix,bc
- add ix,bc
- ld a,d ; Calculating the starting pixel mask
- and %00000111
- inc a
- ld b,a
- ld a,%00000001
- __LineMaskLoop:
- rrca
- djnz __LineMaskLoop
- ld c,a
- ld a,l ; Calculating delta Y and negating the Y increment if necessary
- sub e ; This is the last instruction for which we need the original data
- ld de,12
- jr nc,__LineSkipNeg
- ld de,-12
- neg
- __LineSkipNeg:
- pop hl ; Recalling DX
- ld l,a ; D=DX, E=DY
- cp h
- jr c,__LineHoriz ; Line is rather horizontal than vertical
- __LineVert:
- ld b,l ; Pixel counter
- inc b
- rra ; nc at this point so (A=E/2)
- __LineVLoop:
- call SetLinePix
- add ix,de
- sub h ; Handling gradient
- jr nc,__LineVNext
- add a,l
- rrc c ; Rotating mask
- jr nc,__LineVNext ; Handling byte boundary
- inc ix
- __LineVNext:
- djnz __LineVLoop
- ret
- __LineHoriz:
- ld b,h ; Pixel counter
- inc b
- ld a,h ; Setting up gradient counter
- srl a
- __LineHLoop:
- call SetLinePix
- rrc c ; Rotating mask
- jr nc,__LineHSkip ; Handling byte boundary
- inc ix
- __LineHSkip:
- sub l ; Handling gradient
- jr nc,__LineHNext
- add a,h
- add ix,de
- __LineHNext:
- djnz __LineHLoop
- ret
- __LineEnd:
- RAMCode:
- SetLinePixCode:
- push af ; Saving A
- ld a,(ix+0)
- cpl
- xor c ; Writing pixel to current position
- nop
- ld (ix+0),a
- pop af ; Recalling A
- ret
- IncHLmem1Data:
- IncHLMem1 equ IncHLmem1Data-RAMCode+SetLinePix
- ; speed 1 page total
- ;
- inc l ; 4 4*16384 65536
- ret nz ;11| 5 64*5+16320*11 179840
- inc h ; 4 4*64 256
- ret po ;11| 5 11*63+5 698
- ld h,40h ; 7 7 7
- in a,(6) ; 11 11 11
- inc a ; 4 4 4
- out (6),a ; 11 11 11
- ret ; 10 10 10
- RamCodeEnd:
- ;=============================================================================
- ConvSupplement:
- push de
- push hl
- call HL_Times_A
- ld de,(TempWord4)
- add hl,de
- ld (TempWord4),hl
- pop hl
- ld a,10
- call HL_Times_A
- pop de
- ret
- Conv_OP1:
- ld hl,8478h
- ConvDecAtHL:
- ld a,(hl)
- push hl
- and 0Fh
- srl a
- push af
- inc a
- ld c,a
- ld b,0
- add hl,bc
- ex de,hl
- ld h,b
- ld l,b
- ld (TempWord4),hl
- inc hl
- pop af
- jr nc,$+8
- ld a,(de)
- and 0Fh
- call ConvSupplement
- ld a,(de)
- and $F0
- rlca \ rlca \ rlca \ rlca
- call ConvSupplement
- dec de
- dec c
- ld a,c
- or a
- jr nz,$-20
- pop hl
- ld de,9
- add hl,de
- ld de,(TempWord4)
- ld a,e
- ret
- GetPixelLoc:
- ;Input:
- ; b is X
- ; c is y
- ;Output:
- ; HL points to byte
- ; A is the mask
- ; nc if not computed, c if computed
- ld a,c
- cp 64 \ ret nc
- ld a,b
- cp 96 \ ret nc
- ld l,c
- ld h,0
- ld b,h
- add hl,hl
- add hl,bc
- add hl,hl
- add hl,hl
- ld b,a
- rrca \ rrca \ rrca
- and 0Fh
- ld c,a
- ld a,b
- ld b,0
- add hl,bc
- ld bc,(BufPtr)
- add hl,bc
- and 7
- ld b,a
- inc b
- ld a,1
- rrca
- djnz $-1
- scf
- ret
- ConvHexTo86ECh:
- push bc
- ld h,b \ ld l,c
- call EndOfLine
- pop de
- or a \ sbc hl,de
- ld b,h \ ld c,l
- ld hl,86ECh
- .db $CB,$38,$CB,$19
- HexTok:
- call GetHexAtDE
- call GetHexAtDE
- cpi
- jp pe,HexTok
- ret
- GetHexAtDE:
- ld a,(de)
- cp 3Ah
- jr c,$+4
- sub 7
- inc de
- rld
- ret
- interrupt:
- ; or a \ ret nc
- exx \ ex af,af'
- push af
- push bc
- push de
- push hl
- set 1,(iy+33)
- ld hl,(progPtr)
- push hl
- .db 21h ;first byte of ld hl,**
- IprogPtr:
- .dw 0
- ld a,h \ or l
- jr z,EndExec
- ld (progPtr),hl
- ld (IprogPtr2-interrupt+interruptLoc),hl
- sbc hl,hl \ ld (IprogPtr-interrupt+interruptLoc),hl
- call ParserNext
- .db 21h ;first byte of ld hl,**
- IprogPtr2:
- .dw 0
- ld (IprogPtr-interrupt+interruptLoc),hl
- EndExec:
- ; bit 3,(iy+33)
- ; jr z,CursorDone
- ;
- CursorDone:
- res 1,(iy+33)
- pop hl
- ld (progPtr),hl
- pop hl
- pop de
- pop bc
- pop af
- jp 3Ah
- interrupt_end:
- IsConditional:
- cp $D8 \ ret z ;pause
- cp $CE \ ret z ;if
- cp $D1 \ ret z ;while
- cp $D2 \ ret ;repeat
- SetUpData:
- ;===================================
- ;Set interrupt up
- ;===================================
- di
- bcall(4A20h)
- ld hl,interrupt
- ld de,interruptLoc
- ld bc,interrupt_end - interrupt
- ldir
- ld hl,8000h
- ld de,8001h
- ld bc,256
- ld (hl),8Ah
- ldir
- ld a,80h
- ld i,a
- im 2
- xor a
- ;=================================
- bcall(4570h)
- ld a,r \ ld h,a
- ld a,r \ ld l,a
- ld a,r \ add a,l \ ld l,a
- ld a,r \ adc a,h \ ld h,a
- LD (randSeed),hl
- ld de,SetLinePix
- ld bc,RAMCodeEnd-SetLinePixCode
- ld hl,SetLinePixCode
- ldir
- ld hl,GraphBuf \ ld (BufPtr),hl
- ld hl,PBuf
- ld (PBufPtr),hl
- ld hl,766
- ld (PBuf),hl
- ld a,3
- ld (OutputLogic),a
- ld (TextPauseTime),a
- pop hl
- ld (SPSave),sp ;ED738698
- push hl
- ld hl,FontSet ;21****
- ld (FontPointer),hl ;228A98
- ld hl,0
- ld (8A11h),hl
- ld (8A12h),hl
- ret
- CompatCall:
- ld de,SetLinePix
- ld bc,RAMCodeEnd-SetLinePixCode
- ld hl,SetLinePixCode
- ldir
- jp IsOP1GrammerProg
- ParticlePixelD_LR:
- inc c
- push bc
- call GetPixelLoc
- and (hl)
- pop bc
- ret z
- dec c \ push bc
- ld a,r \ and 2 \ dec a \ add a,b \ ld b,a
- push bc
- call GetPixelLoc
- pop bc
- pop de
- and (hl)
- ret
- RemoveParticle:
- ld c,(hl) \ inc hl
- ld b,(hl)
- ;pixel off
- push bc
- call GetPixelLoc
- pop bc
- jr nc,$+5
- cpl \ and (hl) \ ld (hl),a
- ret
- ;===============================================================
- TokenSet:
- ;===============================================================
- LoadTSA:
- di
- push af \ push bc \ push de \ push hl
- push ix \ pop hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ld de,TSA
- ldir
- pop hl \ pop de \ pop bc
- bit 1,(iy+33)
- jr nz,$+3
- ei
- pop af
- ret
- OP1NameLength:
- ;Returns the name length in HL
- xor a \ ld b,a \ ld c,a
- ld hl,8478h
- cpir
- ld h,a \ ld l,a
- scf \ sbc hl,bc
- ret
- IsOP1GrammerProg:
- ;Outputs:
- ; A is the flash page the data is on
- ; BC is the size of the program
- ; HL points to the data
- ; z is set if it is a grammer var
- ; nz if it isn't
- ld ix,ReadArcData
- call LoadTSA
- call OP1NameLength
- push hl
- bcall(42F1h)
- ld a,b \ pop bc
- ex de,hl
- or a \ jr nz,GetArchSize
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl \ push bc
- ld de,8485h \ push de \ ld bc,4
- ldir \ pop hl \ pop bc
- jr CheckHeader
- GetArchSize:
- ; push af
- ; in a,(6) \ ld (TempWord1+1),a
- ; pop af
- add hl,bc
- ld c,9
- add hl,bc
- ; out (6),a
- bit 7,h
- jr z,$+7
- res 7,h \ set 6,h
- inc a
- ; call nz,IncHLMem1+4
- ld de,8478h+11
- ld bc,5
- push de
- call TSA
- pop de \ ex de,hl \ dec de \ dec de \ dec de
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- CheckHeader:
- push af
- ld a,(hl) \ inc hl \ cp 3Ah \ jr nz,NotHeader
- ld a,(hl) \ inc hl \ cp 30h \ jr nz,NotHeader
- ld a,(hl) \ inc hl \ cp 3Eh
- NotHeader:
- pop hl
- ld a,h
- ex de,hl
- ret nz
- ld (TempWord3),a
- ld (TempWord4),bc
- ld (TempWord5),hl
- ret
- ReadArc:
- ld ix,ReadArcData
- call LoadTSA
- jp TSA
- ReadArcData:
- .dw ReadArcEnd-ReadArc-2
- or a
- jr nz,$+5
- ldir
- ret
- push af \ in a,(6)
- ld (TempWord1),a
- pop af
- out (6),a
- ArcReadLoop equ $-ReadArcData+TSA+2
- dec hl
- call IncHLmem1
- ldi
- jp pe,ArcReadLoop
- push af
- ld a,(TempWord1)
- out (6),a
- pop af
- ret
- ReadArcEnd:
- FindGVarData:
- ld hl,GVarData
- rst 20h
- bcall(42F1h)
- ret nc
- ld hl,3 \ bcall(4E6Ah)
- ret
- GrammerHook:
- .db 83h
- ; jr $
- or a
- jr z,$+4
- ExitHook3:
- xor a \ ret
- push hl
- ; push bc
- ld hl,(8478h)
- ld bc,2305h
- or a
- sbc hl,bc
- ; pop bc
- pop hl
- jr nz,ExitHook3
- push hl
- push de
- push bc
- push af
- di
- bcall(4A20h)
- ld hl,2305h
- xor a \ ld (847Ah),a
- ld (8478h),hl
- bcall(42F1h)
- ex de,hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ld de,8478h
- ldir \ xor a
- ld (de),a
- ; ld hl,9652h
- ld a,5 \ ld (8478h),a
- call SetUpData+4
- call IsOP1GrammerProg
- jr nz,EndHook
- ld hl,8478h
- ld de,8478h+44
- ld bc,9 \ ldir
- pop af
- pop bc
- pop de
- pop hl
- call SelectedProg
- or 1 \ ret
- EndHook:
- ; ld hl,8485h ;location of header
- ; ION=BB6DC918
- ; MOS=BB6DC901
- ; DCS7=BB6DAAC9
- pop af
- pop bc
- pop de
- pop hl
- xor a \ ret
- EndHook2:
- .db 21h,$D3,6
- ld (8103h),hl
- ld a,$C9
- ld (8105h),a
- call FindGVarData
- ex de,hl
- ld e,(hl) \ inc hl
- ld d,(hl) \ inc hl
- ld a,(hl) \ ld h,a \ ld l,3Eh
- ld (8101h),hl \ ex de,hl
- pop af
- pop bc
- pop de
- ex (sp),hl
- jp 8101h
- GetVarName:
- call ParseFullArg
- ld h,b
- ld l,c
- ld a,(hl) \ and 1Fh
- sub 5 \ jr z,ConvTokenName
- dec a \ jr z,ConvTokenName
- sub 15 \ jr z,ConvTokenName
- dec a \ jr z,ConvTokenName
- ld bc,3
- ld d,h \ ld e,l
- add hl,bc
- cp a
- ret
- ConvTokenName:
- jp GetGrammerText
- GetVarInfo:
- ;Returns name in OP1
- ;HL points to SymEntry
- ;DE points to size bytes
- ;BC is the length of the name (for use when finding archived data)
- call GetVarName
- ex de,hl
- ld de,8478h \ push bc
- ldir
- xor a \ ld (de),a
- bcall(42F1h)
- ld a,b \ pop bc
- ret
- GetvarInfo2:
- ;Inputs:
- ; The next argument to parse points to the name of the var to get info about
- ;Outputs:
- ; A is the ending page (start of data)
- ; BC is the size of the var
- ; DE points to the SymEntry
- ; HL points to the data
- ; c is set if the var does not exist
- ld ix,ReadArcData
- call LoadTSA
- call GetVarInfo \ ret c
- ex de,hl
- or a
- jr nz,InfoIsArched
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ret
- InfoIsArched:
- add hl,bc
- ld c,9
- add hl,bc
- bit 7,h
- jr z,$+7
- res 7,h \ set 6,h
- inc a
- push de
- ld de,8478h+11
- ld bc,2
- push de
- call TSA
- pop de
- ex de,hl
- ld c,(hl) \ inc hl
- ld b,(hl) \ inc hl
- ex de,hl
- pop de \ or a
- ret
- GramHandl:
- or a
- jr nz,$+7
- ld a,6
- jp BreakProgram+1
- dec a
- jr nz,$+7
- ld a,14
- jp BreakProgram+1
- dec a
- jr nz,$+7
- ld a,43
- jp BreakProgram+1
- ret
- ONErr:
- xor a \ jr ErrMEM+2
- ErrMEM:
- ld a,1
- ld (8595h),a
- jp ErrorJump
- C_Div_L:
- ;Inputs:
- ; C is the numerator
- ; L is the denominator
- ;Outputs:
- ; A is the remainder
- ; B is 0
- ; C is the result of C/L
- ; D,E,H,L are not changed
- ;
- ld b,8
- xor a
- sla c
- rla
- cp l
- jr c,$+4
- inc c
- sub l
- djnz $-8
- ret
- ;=====================================================
- TileMap1:
- ;=====================================================
- ;Inputs:
- ; DE=MapLoc
- ; BC=TileLoc
- ; HL=MapWidth
- ; A=TileLogic
- ; (TempWord2)=Map X
- ; (TempWord3)=Map Y
- ;=====================================================
- and 7
- ld (TempWord1),a
- push bc
- push hl
- push de
- ld bc,(TempWord3)
- call HL_Times_BC
- ld bc,(TempWord2)
- add hl,bc
- pop bc \ add hl,bc
- pop de \ push hl
- ld hl,-12 \ add hl,de
- pop de
- ld (TempWord2),hl
- xor a \ ld (TempWord1+1),a
- pop bc
- ;DE points to first Map Element
- ;(TempWord2) is the map width thing
- ;BC points to the sprite data
- TileMap1loop:
- ld h,12
- ld a,(de) \ inc de
- dec h
- jr nz,$+9
- ld hl,(TempWord2)
- add hl,de
- ex de,hl
- ld h,12
- push hl
- ld h,0 \ ld l,a
- add hl,hl
- add hl,hl
- add hl,hl
- add hl,bc
- ld a,(TempWord1+1)
- call DrawTile
- ld (TempWord1+1),a
- pop hl
- jr nz,TileMap1Loop+2
- ret
- DrawTile:
- ;Input:
- ; A is the tile number to draw plus
- ; HL points to the sprite data
- ;Output:
- ; A is incremented by 1
- ; BC is not changed
- ; DE is not changed
- ; HL is not changed
- ; z flag set if A is 96
- cp 96 \ ret z
- push af
- push hl
- push de
- push bc
- ex de,hl
- ;DE points to sprite
- ld c,a \ ld l,12
- call C_Div_L
- ;a+bc*96
- ld h,b \ ld l,c
- add hl,hl \ add hl,bc
- add hl,hl \ add hl,hl
- add hl,hl \ add hl,hl
- add hl,hl
- ld c,a \ add hl,bc
- ld bc,(BufPtr)
- add hl,bc
- ld bc,0108h
- ld a,(TempWord1)
- call DrawSpriteXxY
- pop bc
- pop de
- pop hl
- pop af
- inc a
- ret
- ;===============================================================
- HL_SDiv_BC:
- ;===============================================================
- ;Performs signed HL/BC
- ;Speed: 1494 cycles
- ;Size: 23 bytes +31 bytes
- ;Inputs:
- ; HL is the numerator
- ; BC is the denominator
- ;Outputs:
- ; HL is the quotient
- ; DE is the remainder
- ; BC is not changed
- ; A is 0
- ; z flag is set
- ; c flag is reset
- ;===============================================================
- ld a,h
- xor b
- and 128
- push af
- absHL:
- bit 7,h
- jr z,absBC
- ld a,l \ cpl \ ld l,a
- ld a,h \ cpl \ ld h,a
- inc hl
- absBC:
- bit 7,b
- jr z,$+9
- ld a,c \ cpl \ ld c,a
- ld a,b \ cpl \ ld b,a
- inc bc
- add hl,hl
- ld a,15
- ld de,0
- SDiv_Loop_1:
- add hl,hl
- ex de,hl
- adc hl,hl
- or a
- sbc hl,bc
- jr c,$+5
- inc e
- jr $+3
- add hl,bc
- ex de,hl
- dec a
- jr nz,SDiv_Loop_1
- pop af
- ret z
- ld a,l \ cpl \ ld l,a
- ld a,h \ cpl \ ld h,a
- inc hl
- ret
- VPutC:
- ld b,a
- ld hl,(FontPointer)
- ld de,254
- inc e \ inc e
- add hl,de
- ld e,(hl)
- djnz $-4
- ld d,e \ inc hl
- ld e,(hl) \ inc hl
- ex de,hl
- push hl
- ld bc,(TextRow)
- ld a,b \ add a,l
- cp 97
- jr c,geykley
- ld a,c
- add a,h \ ld c,a
- ld a,l \ ld b,0
- geykley:
- ld l,a
- ld a,c
- cp 58
- jr c,gerkeb
- xor a
- ld c,a
- gerkeb:
- ld h,l
- ld l,a
- CoordAdj:
- ; jr $
- ld (TextRow),hl
- ; ld a,c \ cp l
- ; jr z,$+3
- ; ld c,l
- ; ld a,b \ sub h
- ; jr c,$+3
- ; ld b,h
- pop hl
- ld a,(OutputLogic)
- jp DrawPixelCoordSprite
- p_FreqOut:
- xor a
- __FreqOutLoop1:
- push bc
- ld e,a
- __FreqOutLoop2:
- ld a,h
- or l
- jr z,__FreqOutDone
- dec hl
- dec bc
- ld a,b
- or c
- jr nz,__FreqOutLoop2
- ld a,e
- xor %00000011
- scf
- __FreqOutDone:
- pop bc
- out ($00),a
- ret nc
- jr __FreqOutLoop1
- __FreqOutEnd:
- PlayNoteAtHL:
- ld a,(hl)
- inc a
- PlayNoteA:
- or a \ ret z
- ld c,a
- cp 80h
- jr c,$+14
- and 7Fh
- or a \ ret z
- ld b,a
- ei
- halt
- djnz $-1
- di
- xor a
- ret
- push de
- push hl
- ld d,a
- ld hl,(TempWord1)
- call RoundHL_Div_C
- ld c,d
- push hl
- ld b,c
- ex (sp),hl \ ex (sp),hl \ ex (sp),hl \ ex (sp),hl
- djnz $-4
- inc d
- ld a,d
- out (0),a
- pop hl
- dec hl
- ld a,h
- or l
- jr nz,$-16
- xor a
- out (0),a
- pop hl
- pop de
- ret
- RoundHL_Div_C:
- ;Inputs:
- ; HL is the numerator
- ; C is the denominator
- ;Outputs:
- ; A is twice the remainder of the unrounded value
- ; B is 0
- ; C is not changed
- ; DE is not changed
- ; HL is the rounded quotient
- ; c flag set means no rounding was performed
- ; reset means the value was rounded
- ;
- ld b,16
- xor a
- add hl,hl
- rla
- cp c
- jr c,$+4
- inc l
- sub c
- djnz $-7
- add a,a
- cp c
- jr c,$+3
- inc hl
- ret
- CopyToRAM:
- ; jr $
- ld a,83h
- out (7),a
- ld hl,(4004h)
- ld b,l \ ld c,h
- ld hl,4080h
- ld de,8080h
- ldir
- out (6),a
- ld a,81h
- out (7),a
- jp EndOfEntries
- SearchLine:
- ;Inputs:
- ; HL points to the start
- ; DE is the negative of the number of bytes to search
- ; BC is the negative of the line number
- ; A is the line byte
- ;Outputs:
- ; A is not changed
- ; BC is the length of the line
- ; DE is 0 if the line was not found
- ; HL points to the line
- ; nc flag set if the line was found
- SearchLoop:
- cp (hl) \ inc hl \ jr z,$+10
- inc e \ jr nz,SearchLoop
- inc d \ jr nz,SearchLoop
- scf
- ret
- inc c \ jr nz,SearchLoop
- inc b \ jr nz,SearchLoop
- push hl
- FindLineLength:
- inc e \ jr nz,$+5
- inc d \ jr z,$+7
- inc bc
- cp (hl) \ inc hl \ jr nz,FindLineLength
- pop hl
- or a
- ret
- ZeroProg:
- .db 5,0
- ZeroAVar:
- .db 21,0
- ChooseProgText:
- .db "Select a program:",0
- GramTempName:
- .db 16h,"GramTemp"
- GVarData:
- .db 15h,"GVarData"
- .end
- ;c is bc>hl
- ;z is bc=hl
- ; or a
- ; sbc hl,bc
- ; add hl,bc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement