-
Notifications
You must be signed in to change notification settings - Fork 0
/
kret.pas
183 lines (159 loc) · 3.57 KB
/
kret.pas
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// {$librarypath '~/Atari/MadPascal/blibs/'}
{$librarypath './sfx_engine/'}
{$librarypath './song/'}
// {$DEFINE ROMOFF}
{$DEFINE NOROMFONT}
uses cio, SFX_API, atari, hsc_util;
// {$define no-title-music}
// {$DEFINE INCLUDE_LANG}
{$r song/resource.rc}
const
{$i memory.inc}
{$i types.pas}
{$i const.pas}
{$IFDEF INCLUDE_LANG}
{$DEFINE POLISH}
{$IFDEF DEUTCH}
{$r de.rc}
{$ENDIF}
{$IFDEF ENGLISH}
{$r en.rc}
{$ENDIF}
{$IFDEF CZECH}
{$r cz.rc}
{$ENDIF}
{$IFDEF POLISH}
{$r pl.rc}
{$ENDIF}
{$ENDIF}
var
firstRun:boolean = True;
scr:Array[0..839] of Byte absolute SCREEN_ADDR;
string_history :array[0..3,0..2] of Byte absolute STRINGS_PointerS_ADDR;
strings_Pointers:array[0..6] of Word absolute STRINGS_PointerS_ADDR+12;
strings_data :array[0..0] of Byte absolute STRINGS_DATA_ADDR;
{$r resources.rc}
{$i include/dli.pas}
{$i include/vbli.pas}
{$i include/helpers.pas}
{$i include/strings.pas}
{$i include/block.pas}
{$i include/scroll.pas}
var
moleX,moleY, // mole position on screen (in characters)
mX,mY, // mole position on screen (in pixels)
omY, // old mole Y position (in pixels)
moleOfs, // mole offset in buffer
moleSprite:Byte; // mole sprite number
moleState, // mole current state
oMoleState, //
blockState:Byte; // block fall speed in frames
newBlocks, // indicate, how many new block is created after blocks fallen
blocksFallen:Byte; // indicate, haw many block have fallen
vanishingBlockOfs:Byte; //
status:^TStatus; // in game status
gameOver, // indicate for Game Over
breakGame, // indicate for break game (press ESC key in main game)
redraw:Boolean; // Playfield redraw
// timers
moleTime:Byte absolute TIMER1; // mole animation timer
moleFallenTime:Byte absolute TIMER2; // The time after which the mole falls lower
blocksTime:Byte absolute TIMER3; // blocks drop timer
vanishBreakTime:Byte absolute TIMER4; // block break timer
vanishTime:Word absolute TIMER5; // vanish block timer
animTime:Byte absolute TIMER6; //
procedure Exit_Game();
begin
offVideo();
SFX_Off();
if isMIDIDrv then
asm
sec
jsr $200c
end;
delay(5);
NMIEN:=%00000000;
SetIntVec(iVBL, oldVBL);
SetIntVec(iDLI, oldDLI);
NMIEN:=%01000000;
SDMCTL:=%00101010;
PMCTL:=0;// GPRIOR:=%00100001;
halt(1);
end;
{$i include/sprite.pas}
{$i game/game_status.pas}
{$i game/screens.pas}
{$i game/title.pas}
{$i game/game_over.pas}
{$i game/game.pas}
{$i game/history.pas}
{$i game/bests.pas}
{$i game/menu.pas}
procedure init();
var
_tm:word absolute $13;
begin
asm
wait:
lda _TM
bne @+
lda _TM+1
cmp #50
jcc wait
@:
end;
// clear all timers
fillchar(pointer(TIMER1),7,0);
// turn off video
SDMCTL:=0;
// blocks vectors initialize
defvec:=BLOCKS_DEF_ADDR; lstvec:=BLOCKS_LIST_ADDR;
// save old DL Interrupt
GetIntVec(iDLI, oldDLI);
// SFX Lib initialize
fillbyte(pointer(MIDI_CHANNELS_ADDR),48,$ff);
INIT_SFXEngine();
NMIEN:=%00000000;
GetIntVec(iVBL, oldVBL);
SetIntVec(iVBL, @myVBL);
NMIEN:=%01000000;
createBests();
// check MIDI Driver
asm
ldy #15
driverTestLoop:
lda $2000,y
cmp #$4c ; $4c=jmp
beq next
ldx #0
beq endDriverTest
next:
dey
dey
dey
bpl driverTestLoop
ldx #1
endDriverTest:
stx MAIN.SFX_API.isMIDIDrv
end;
// Initialize MIDI Driver
if isMIDIDrv then
asm
jsr $2003
end;
resetScroll;
end;
begin
init();
repeat
titleInScreen();
menuLoop();
// ready screen for player
ReadyScreen();
initNewGame();
// prepare game
GameScreen();
gameLoop();
if gameover then moleDie();
until false;
end.