-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.asm
102 lines (82 loc) · 2.57 KB
/
main.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
////////////////////////////////////////////////////////////////////////////////
//
// Project : ForestSaver - https://github.com/intoinside/ForestSaver
// Target : Commodore 64
// Author : Raffaele Intorcia - raffaele.intorcia@gmail.com
//
// Main source code. Game initialization and main loop container.
//
////////////////////////////////////////////////////////////////////////////////
#importonce
.segmentdef Code [start=$0810]
.segmentdef MapData [start=$4000]
.segmentdef MapDummyArea [start=$5000]
.segmentdef Sprites [start=$5400]
.segmentdef Charsets [start=$7800]
.segmentdef CharsetsColors [start=$c000]
.segmentdef Dialogs [start=$c100]
#import "_allimport.asm"
.file [name="./main.prg", segments="Code, Charsets, CharsetsColors, MapData, Sprites, Dialogs", modify="BasicUpstart", _start=$0810]
.file [name="./ForestSaver.prg", segments="Code, Charsets, CharsetsColors, MapData, Sprites, Dialogs", modify="BasicUpstart", _start=$0810]
.disk [filename="./ForestSaver.d64", name="FORESTSAVER", id="C2022", showInfo]
{
[name="----------------", type="rel"],
[name="--- RAFFAELE ---", type="rel"],
[name="--- INTORCIA ---", type="rel"],
[name="----------------", type="rel"],
[name="FORESTSAVER", type="prg", segments="Code, Charsets, CharsetsColors, MapData, Sprites, Dialogs", modify="BasicUpstart", _start=$0810],
[name="----------------", type="rel"]
}
.segment Code
* = * "Entry"
Entry: {
MainGameSettings()
jmp GamePlay
}
* = * "Main GamePlay"
GamePlay: {
// Show intro screen until player start a new game
jsr Intro.Manager
// Init a new game
InitNewGame()
// Play on level 1
jsr Level1.Manager
lda GameEnded
bne GamePlay
// Play on level 2
jsr Level2.Manager
lda GameEnded
bne GamePlay
// Play on level 3
jsr Level3.Manager
jmp GamePlay
}
// Initialize vars for new game
.macro InitNewGame() {
lda #0
sta GameEnded
}
// Initial environment setup
.macro MainGameSettings() {
// Switch out Basic so there is available ram on $a000-$bfff
lda $01
ora #%00000010
and #%11111110
sta $01
// Set Vic bank 1 ($4000-$7fff)
lda #%00000010
sta CIA2.PORT_A
// Set Multicolor mode on
lda #%00011000
sta c64lib.CONTROL_2
lda #$ff
sta c64lib.SPRITE_COL_MODE
jsr Keyboard.Init
}
GameEnded: // $00 - Game in progress
.byte $00 // $ff - Player dead, game ended
#import "_intro.asm"
#import "_level1.asm"
#import "_level2.asm"
#import "_level3.asm"
#import "_keyboard.asm"