-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbytecode.mem
51 lines (44 loc) · 1.78 KB
/
bytecode.mem
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
// BALL_IMAGE EQU 0x031E
// BALL_X EQU 0x00
// BALL_Y EQU 0x01
// BALL_ZOOM EQU 0x02
// SPEED EQU 0x03
// BALL_VX EQU 0x04
// BALL_VY EQU 0x05
// PAUSE_SLICES EQU 0xFF
// init: (0000)
00 FF 00 02 // mov [PAUSE_SLICES], 2 ; 2*20ms = 40ms per frame = 25 frames / sec
00 03 00 01 // mov [SPEED], 1
00 00 00 A0 // mov [BALL_X], 160
00 01 00 64 // mov [BALL_Y], 100
00 02 00 40 // mov [BALL_ZOOM], 0x40
01 04 03 // mov [BALL_VX], [SPEED]
02 04 03 // add [BALL_VX], [SPEED]
01 05 03 // mov [BALL_VY], [SPEED]
02 05 03 // add [BALL_VY], [SPEED]
0b 03 FF // setPalette 0x03
0D 00 // selectVideoPage 0x00
// mainloop: (0025)
0E 00 07 // fill page=0x00, color=0x07
55 01 8F 00 01 02 // video offset=BALL_IMAGE, x=[BALL_X], y=[BALL_Y], zoom=[BALL_ZOOM]
10 00 // blitFramebuffer 0x00
01 00 00 // mov [0x00], [0x00] // 3 byte nop (to avoid re-calculating all addresses below)
13 00 03 // sub [BALL_X], [SPEED]
02 00 04 // add [BALL_X], [BALL_VX]
13 01 03 // sub [BALL_Y], [SPEED]
02 01 05 // add [BALL_Y], [BALL_VY]
0A 44 00 01 40 00 4A // jl [BALL_X], 320, _1
00 04 00 00 // mov [BALL_VX], 0
// _1: (004A)
0A 02 00 00 00 56 // jg [BALL_X], 0, _2
01 04 03 // mov [BALL_VX], [SPEED]
02 04 03 // add [BALL_VX], [SPEED]
// _2: (0056)
0A 04 01 C8 00 60 // jl [BALL_Y], 200, _3
00 05 00 00 // mov [BALL_VY], 0
// _3: (0060)
0A 02 01 00 00 6C // jg [BALL_Y], 0, _4
01 05 03 // mov [BALL_VY], [SPEED]
02 05 03 // add [BALL_VY], [SPEED]
// _4: (006C)
07 00 25 // jmp mainloop