Subversion Repositories Kolibri OS

Rev

Rev 8725 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8725 rgimad 1
; Author: rgimad (2021)
2
; License: GNU GPL v2
3
 
4
format binary as ""
5
use32
6
org     0
7
db      'MENUET01'    ; signature
8
dd      1             ; header version
9
dd      start         ; entry point
10
dd      _i_end         ; end of image
11
dd      _mem          ; required memory size
12
dd      _stacktop      ; address of stack top
13
dd      cmdline       ; buffer for command line arguments
14
dd      0             ; buffer for path
15
 
16
include 'constants.inc'
17
 
18
; application's entry point
19
align 4
20
start:
8734 rgimad 21
        mcall   68, 11
22
        mcall   68, 12, IMGBUF_SIZE
23
        mov     dword [imgbuf_ptr], eax
8725 rgimad 24
 
25
        stdcall chip8_init ; initialize
26
 
27
        DEBUGF  DBG_INFO, "app started, args = %s\n", cmdline
28
        DEBUGF  DBG_INFO, "MAX_GAME_SIZE = %x = %u\n", MAX_GAME_SIZE, MAX_GAME_SIZE
29
 
30
;        xor     ecx, ecx
31
; @@:
32
;        mov     al, byte [chip8_fontset + ecx]
33
;        DEBUGF  DBG_INFO, "%x ", al
34
;        cmp     ecx, 79
35
;        je      @f
36
;        inc     ecx
37
;        jmp     @b
38
; @@:
39
 
40
        mov     dword [fread_struct.filename], cmdline
41
        stdcall chip8_loadgame, fread_struct
42
        jz      .file_not_found
43
 
44
        DEBUGF  DBG_INFO, "file was read. bytes: %x %x %x..\n", [memory + 0x200], [memory + 0x200 + 4], [memory + 0x200 + 8]
45
 
46
        ; mov     byte [gfx + 5], 1
47
        ; mov     byte [gfx + 64], 1
48
        ; mov     byte [gfx + 65], 1
49
        ; mov     byte [gfx + 64*2 + 3], 1
50
 
51
.event_loop:
8734 rgimad 52
        mcall   23, CLOCK_RATE ; wait for event with CLOCK_RATE timeout
8725 rgimad 53
        ;DEBUGF  DBG_INFO, "evenp loop iter i\n"
54
 
55
        cmp     eax, 1
56
        je      .event_redraw
57
 
58
        cmp     eax, 2
59
        je      .event_key
60
 
61
        cmp     eax, 3
62
        je      .event_button
63
 
64
        jmp     .event_default
65
 
66
        .event_redraw:
67
                stdcall draw_main_window
68
                jmp     .event_default
69
 
70
        .event_key:
71
                mcall   2
72
                stdcall keyboard_update, eax
73
                DEBUGF  DBG_INFO, "key scancode %x\n", eax:4
74
                jmp     .event_default
75
 
76
        .event_button:
77
                mcall   17
78
                cmp     ah, 1
79
                jne     .event_default
80
                mcall   -1
81
 
82
        .event_default:
83
                stdcall chip8_emulatecycle
84
                cmp     byte [chip8_draw_flag], 0
85
                jz      @f
86
 
87
                ; mov     byte [gfx + 64*2 + 3], 1 ; DBG
88
 
89
                stdcall draw_screen
90
                mov     byte [chip8_draw_flag], 0
91
        @@:
92
                stdcall chip8_tick
93
        jmp     .event_loop
94
 
95
.file_not_found:
96
        DEBUGF  DBG_ERR, "Unable to open game file! eax = %u\n", eax
97
        jmp     .exit
98
 
99
.exit:
100
        mov     eax, -1
101
        int     0x40
102
 
103
;;;;;;;;;;;;;;;;;;;;;;;
104
 
105
 
106
include 'gui.inc'
107
 
108
include 'emu.inc'
109
 
110
include 'utils.inc'
111
 
112
include 'data.inc'
113
        rb      4096 ; reserve for main thread stack
114
align 16
115
_stacktop:
116
 
117
_mem: