Fix example programs; allow externals to be called.
--HG--
rename : eg/hi.60p => eg/hello-world.60p
Cat's Eye Technologies
11 years ago
0 | |
assign byte table screen $0400
|
1 | |
assign byte table screen2 1274
|
2 | |
assign byte table screen3 1524
|
3 | |
assign byte table screen4 1774
|
|
0 |
assign byte[256] screen $0400
|
|
1 |
assign byte[256] screen2 1274
|
|
2 |
assign byte[256] screen3 1524
|
|
3 |
assign byte[256] screen4 1774
|
4 | 4 |
|
5 | |
assign byte table colormap 55296
|
6 | |
assign byte table colormap2 55546
|
7 | |
assign byte table colormap3 55796
|
8 | |
assign byte table colormap4 56046
|
|
5 |
assign byte[256] colormap 55296
|
|
6 |
assign byte[256] colormap2 55546
|
|
7 |
assign byte[256] colormap3 55796
|
|
8 |
assign byte[256] colormap4 56046
|
9 | 9 |
|
10 | 10 |
assign byte vic_border 53280
|
11 | |
assign byte table vic_bg 53281
|
|
11 |
assign byte[4] vic_bg 53281
|
12 | 12 |
|
13 | 13 |
assign vector cinv 788
|
14 | 14 |
reserve vector save_cinv
|
0 | |
assign byte table screen $0400
|
1 | |
assign byte table screen2 1274
|
2 | |
assign byte table screen3 1524
|
3 | |
assign byte table screen4 1774
|
|
0 |
assign byte[256] screen $0400
|
|
1 |
assign byte[256] screen2 1274
|
|
2 |
assign byte[256] screen3 1524
|
|
3 |
assign byte[256] screen4 1774
|
4 | 4 |
|
5 | |
assign byte table colormap 55296
|
6 | |
assign byte table colormap2 55546
|
7 | |
assign byte table colormap3 55796
|
8 | |
assign byte table colormap4 56046
|
|
5 |
assign byte[256] colormap 55296
|
|
6 |
assign byte[256] colormap2 55546
|
|
7 |
assign byte[256] colormap3 55796
|
|
8 |
assign byte[256] colormap4 56046
|
9 | 9 |
|
10 | 10 |
assign byte vic_border 53280
|
11 | |
assign byte table vic_bg 53281
|
|
11 |
assign byte[4] vic_bg 53281
|
12 | 12 |
|
13 | 13 |
assign byte joy2 $dc00
|
14 | 14 |
|
|
0 |
reserve byte[13] message: "HELLO, WORLD!"
|
|
1 |
external chrout 65490
|
|
2 |
routine main {
|
|
3 |
ldy #0
|
|
4 |
repeat bne {
|
|
5 |
lda message, y
|
|
6 |
jsr chrout
|
|
7 |
iny
|
|
8 |
cpy #13
|
|
9 |
}
|
|
10 |
lda #13
|
|
11 |
jsr chrout
|
|
12 |
}
|
0 | |
external chrout 65490
|
1 | |
routine main {
|
2 | |
lda #72
|
3 | |
jsr chrout
|
4 | |
lda #73
|
5 | |
jsr chrout
|
6 | |
lda #13
|
7 | |
jsr chrout
|
8 | |
}
|
0 | |
assign byte table screen 1024
|
|
0 |
assign byte[256] screen 1024
|
1 | 1 |
reserve byte value
|
2 | 2 |
routine main {
|
3 | 3 |
lda #0
|
52 | 52 |
updateRoutCtx nm dst (UpdatedWith src) routCtx
|
53 | 53 |
|
54 | 54 |
checkInstr nm (JSR name) progCtx routCtx =
|
55 | |
let
|
56 | |
Just calledRout = lookupRoutine program name
|
57 | |
in
|
58 | |
case Map.lookup name progCtx of
|
59 | |
Just calledRoutCtx ->
|
60 | |
mergeRoutCtxs nm routCtx calledRoutCtx calledRout
|
61 | |
Nothing ->
|
62 | |
error ("can't call routine '" ++ name ++ "' before it is defined")
|
|
55 |
case lookupRoutine program name of
|
|
56 |
Just calledRout ->
|
|
57 |
case Map.lookup name progCtx of
|
|
58 |
Just calledRoutCtx ->
|
|
59 |
mergeRoutCtxs nm routCtx calledRoutCtx calledRout
|
|
60 |
Nothing ->
|
|
61 |
error ("can't call routine '" ++ name ++ "' before it is defined")
|
|
62 |
Nothing ->
|
|
63 |
-- it must be an external.
|
|
64 |
-- TODO: merge in any poisoning/outputs that are declared
|
|
65 |
-- on the external. for now,
|
|
66 |
routCtx
|
|
67 |
|
63 | 68 |
checkInstr nm (CMP reg addr) progCtx routCtx =
|
64 | 69 |
-- TODO: mark Carry bit as "touched" here
|
65 | 70 |
routCtx
|
68 | 68 |
checkAndTransformProgram :: Program -> Maybe Program
|
69 | 69 |
checkAndTransformProgram program =
|
70 | 70 |
if
|
71 | |
trueOrDie "missing 'main' routine" (routineDeclared "main" program) &&
|
|
71 |
trueOrDie ("missing 'main' routine: " ++ show program) (routineDeclared "main" program) &&
|
72 | 72 |
trueOrDie "duplicate location name" (noDuplicateDecls program) &&
|
73 | 73 |
trueOrDie "duplicate routine name" (noDuplicateRoutines program) &&
|
74 | 74 |
trueOrDie "undeclared routine" (noUseOfUndeclaredRoutines program) &&
|
110 | 110 |
isInitializedDecl (Assign _ _ _) = False
|
111 | 111 |
isInitializedDecl (Reserve _ _ (v:vs)) = True
|
112 | 112 |
isInitializedDecl (Reserve _ _ []) = False
|
|
113 |
isInitializedDecl _ = False
|
113 | 114 |
|
114 | 115 |
declaredLocationNames (Program decls _) =
|
115 | 116 |
map (getDeclLocationName) (filter (isLocationDecl) decls)
|