mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-13 11:33:16 +00:00
Get eg/* working again.
This commit is contained in:
parent
b455709ef1
commit
5e4bf5caad
@ -19,6 +19,7 @@ Emitting an `if`.
|
||||
| }
|
||||
| sta screen
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= lda screen
|
||||
= cmp screen
|
||||
@ -46,6 +47,7 @@ Emitting a `repeat`.
|
||||
| }
|
||||
| sty screen
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= ldy zero
|
||||
=
|
||||
@ -77,6 +79,7 @@ Nested ifs.
|
||||
| lda #3
|
||||
| }
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= BEQ _label_3
|
||||
= lda #3
|
||||
@ -113,6 +116,7 @@ Installing an interrupt handler (at the Kernal level, i.e. with CINV)
|
||||
| inc screen
|
||||
| jmp (save_cinv)
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= sei
|
||||
= lda cinv
|
||||
@ -141,6 +145,7 @@ Copy command: immediate -> byte
|
||||
| routine main {
|
||||
| copy #23 position
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= lda #23
|
||||
= sta position
|
||||
@ -154,6 +159,7 @@ Copy command: immediate -> word
|
||||
| routine main {
|
||||
| copy #$0400 position
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= lda #0
|
||||
= sta position
|
||||
|
@ -203,6 +203,7 @@ Big test for parsing and emitting instructions.
|
||||
| ora #8
|
||||
| ora vbyte
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= lda #4
|
||||
= ldx #0
|
||||
@ -276,6 +277,7 @@ Big test for parsing and emitting instructions.
|
||||
| eor #5
|
||||
| eor vbyte
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= asl
|
||||
= asl vbyte
|
||||
@ -305,6 +307,7 @@ Big test for parsing and emitting instructions.
|
||||
| lda #2
|
||||
| }
|
||||
| }
|
||||
= jmp main
|
||||
= main:
|
||||
= pha
|
||||
= sei
|
||||
|
78
eg/demo.60p
78
eg/demo.60p
@ -21,21 +21,6 @@ reserve byte value
|
||||
reserve word m
|
||||
reserve word n
|
||||
|
||||
routine main {
|
||||
lda #5
|
||||
sta vic_border
|
||||
lda #0
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
clc
|
||||
repeat bcc { }
|
||||
}
|
||||
|
||||
routine reset_position {
|
||||
lda #$00
|
||||
sta <position
|
||||
@ -43,20 +28,6 @@ routine reset_position {
|
||||
sta >position
|
||||
}
|
||||
|
||||
routine our_cinv {
|
||||
lda value
|
||||
inc value
|
||||
ldy #0
|
||||
sta (position), y
|
||||
jsr increment_pos
|
||||
jsr compare_pos
|
||||
if beq {
|
||||
jsr reset_position
|
||||
} else {
|
||||
}
|
||||
jmp (save_cinv)
|
||||
}
|
||||
|
||||
routine increment_pos {
|
||||
clc
|
||||
lda <position
|
||||
@ -67,6 +38,16 @@ routine increment_pos {
|
||||
sta >position
|
||||
}
|
||||
|
||||
routine compare_16_bit {
|
||||
lda >m
|
||||
cmp >n
|
||||
if beq {
|
||||
lda <m
|
||||
cmp <n
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
routine compare_pos {
|
||||
lda <position
|
||||
sta <m
|
||||
@ -79,16 +60,6 @@ routine compare_pos {
|
||||
jsr compare_16_bit
|
||||
}
|
||||
|
||||
routine compare_16_bit {
|
||||
lda >m
|
||||
cmp >n
|
||||
if beq {
|
||||
lda <m
|
||||
cmp <n
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
routine clear_screen {
|
||||
ldy #0
|
||||
repeat bne {
|
||||
@ -108,3 +79,32 @@ routine clear_screen {
|
||||
cpy #250
|
||||
}
|
||||
}
|
||||
|
||||
routine our_cinv {
|
||||
lda value
|
||||
inc value
|
||||
ldy #0
|
||||
sta (position), y
|
||||
jsr increment_pos
|
||||
jsr compare_pos
|
||||
if beq {
|
||||
jsr reset_position
|
||||
} else {
|
||||
}
|
||||
jmp (save_cinv)
|
||||
}
|
||||
|
||||
routine main {
|
||||
lda #5
|
||||
sta vic_border
|
||||
lda #0
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
clc
|
||||
repeat bcc { }
|
||||
}
|
||||
|
86
eg/game.60p
86
eg/game.60p
@ -26,39 +26,6 @@ reserve word delta
|
||||
reserve byte value
|
||||
reserve word compare_target
|
||||
|
||||
routine main {
|
||||
lda #5
|
||||
sta vic_border
|
||||
lda #0
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
clc
|
||||
repeat bcc { }
|
||||
}
|
||||
|
||||
routine our_cinv {
|
||||
lda #32
|
||||
ldy #0
|
||||
sta (position), y
|
||||
jsr read_stick
|
||||
jsr advance_pos
|
||||
jsr check_new_position_in_bounds
|
||||
if bcs {
|
||||
jsr install_new_position
|
||||
} else { }
|
||||
|
||||
lda #81
|
||||
ldy #0
|
||||
sta (position), y
|
||||
|
||||
jmp (save_cinv)
|
||||
}
|
||||
|
||||
routine reset_position {
|
||||
copy #$0400 position
|
||||
}
|
||||
@ -77,6 +44,16 @@ routine install_new_position {
|
||||
copy new_position position
|
||||
}
|
||||
|
||||
routine compare_new_pos {
|
||||
lda >new_position
|
||||
cmp >compare_target
|
||||
if beq {
|
||||
lda <new_position
|
||||
cmp <compare_target
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
routine check_new_position_in_bounds {
|
||||
copy #$07e8 compare_target ; just past bottom of screen
|
||||
jsr compare_new_pos
|
||||
@ -96,16 +73,6 @@ routine check_new_position_in_bounds {
|
||||
}
|
||||
}
|
||||
|
||||
routine compare_new_pos {
|
||||
lda >new_position
|
||||
cmp >compare_target
|
||||
if beq {
|
||||
lda <new_position
|
||||
cmp <compare_target
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
routine clear_screen {
|
||||
ldy #0
|
||||
repeat bne {
|
||||
@ -163,3 +130,36 @@ routine read_stick {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
routine our_cinv {
|
||||
lda #32
|
||||
ldy #0
|
||||
sta (position), y
|
||||
jsr read_stick
|
||||
jsr advance_pos
|
||||
jsr check_new_position_in_bounds
|
||||
if bcs {
|
||||
jsr install_new_position
|
||||
} else { }
|
||||
|
||||
lda #81
|
||||
ldy #0
|
||||
sta (position), y
|
||||
|
||||
jmp (save_cinv)
|
||||
}
|
||||
|
||||
routine main {
|
||||
lda #5
|
||||
sta vic_border
|
||||
lda #0
|
||||
sta vic_bg
|
||||
jsr reset_position
|
||||
jsr clear_screen
|
||||
sei {
|
||||
copy cinv save_cinv
|
||||
copy routine our_cinv to cinv
|
||||
}
|
||||
clc
|
||||
repeat bcc { }
|
||||
}
|
||||
|
@ -109,11 +109,9 @@ analyzeProgram program@(Program decls routines) =
|
||||
checkInstr NOP progCtx routCtx =
|
||||
routCtx
|
||||
|
||||
{-
|
||||
checkInstr instr _ _ = error (
|
||||
"Internal error: sixtypical doesn't know how to " ++
|
||||
"analyze '" ++ (show instr) ++ "'")
|
||||
-}
|
||||
|
||||
--
|
||||
-- Utility function:
|
||||
@ -133,6 +131,8 @@ mergeRoutCtxs routCtx calledRoutCtx calledRout@(Routine name outputs _) =
|
||||
Map.insert location usage routCtxAccum
|
||||
False ->
|
||||
Map.insert location (PoisonedWith ulocation) routCtxAccum
|
||||
PoisonedWith ulocation ->
|
||||
Map.insert location usage routCtxAccum
|
||||
in
|
||||
Map.foldrWithKey (poison) routCtx calledRoutCtx
|
||||
|
||||
|
@ -7,6 +7,7 @@ import Data.Bits
|
||||
import SixtyPical.Model
|
||||
|
||||
emitProgram p@(Program decls routines) =
|
||||
" jmp main\n" ++
|
||||
emitRoutines p routines ++
|
||||
emitDecls p decls
|
||||
|
||||
|
@ -41,6 +41,7 @@ nspaces = do
|
||||
|
||||
toplevel :: Parser Program
|
||||
toplevel = do
|
||||
spaces
|
||||
decls <- many decl
|
||||
routines <- many routine
|
||||
return $ Program decls routines
|
||||
|
Loading…
x
Reference in New Issue
Block a user