Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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:
  21.  
  22.         stdcall chip8_init ; initialize
  23.  
  24.         DEBUGF  DBG_INFO, "app started, args = %s\n", cmdline
  25.         DEBUGF  DBG_INFO, "MAX_GAME_SIZE = %x = %u\n", MAX_GAME_SIZE, MAX_GAME_SIZE
  26.  
  27. ;        xor     ecx, ecx
  28. ; @@:
  29. ;        mov     al, byte [chip8_fontset + ecx]
  30. ;        DEBUGF  DBG_INFO, "%x ", al
  31. ;        cmp     ecx, 79
  32. ;        je      @f
  33. ;        inc     ecx
  34. ;        jmp     @b
  35. ; @@:
  36.  
  37.         mov     dword [fread_struct.filename], cmdline
  38.         stdcall chip8_loadgame, fread_struct
  39.         jz      .file_not_found
  40.  
  41.         DEBUGF  DBG_INFO, "file was read. bytes: %x %x %x..\n", [memory + 0x200], [memory + 0x200 + 4], [memory + 0x200 + 8]
  42.        
  43.         ; mov     byte [gfx + 5], 1
  44.         ; mov     byte [gfx + 64], 1
  45.         ; mov     byte [gfx + 65], 1
  46.         ; mov     byte [gfx + 64*2 + 3], 1
  47.  
  48. .event_loop:
  49.         mcall   23, CLOCK_RATE ; wait for event with CLOCK_RATE timeout
  50.         ;DEBUGF  DBG_INFO, "evenp loop iter i\n"
  51.  
  52.         cmp     eax, 1
  53.         je      .event_redraw
  54.  
  55.         cmp     eax, 2
  56.         je      .event_key
  57.  
  58.         cmp     eax, 3
  59.         je      .event_button
  60.  
  61.         jmp     .event_default
  62.  
  63.         .event_redraw:
  64.                 stdcall draw_main_window
  65.                 jmp     .event_default
  66.  
  67.         .event_key:
  68.                 mcall   2
  69.                 stdcall keyboard_update, eax
  70.                 DEBUGF  DBG_INFO, "key scancode %x\n", eax:4
  71.                 jmp     .event_default
  72.  
  73.         .event_button:
  74.                 mcall   17
  75.                 cmp     ah, 1
  76.                 jne     .event_default
  77.                 mcall   -1
  78.  
  79.         .event_default:
  80.                 stdcall chip8_emulatecycle
  81.                 cmp     byte [chip8_draw_flag], 0
  82.                 jz      @f  
  83.  
  84.                 ; mov     byte [gfx + 64*2 + 3], 1 ; DBG
  85.  
  86.                 stdcall draw_screen
  87.                 mov     byte [chip8_draw_flag], 0
  88.         @@:
  89.                 stdcall chip8_tick
  90.         jmp     .event_loop
  91.  
  92. .file_not_found:
  93.         DEBUGF  DBG_ERR, "Unable to open game file! eax = %u\n", eax
  94.         jmp     .exit
  95.  
  96. .exit:
  97.         mov     eax, -1
  98.         int     0x40
  99.  
  100. ;;;;;;;;;;;;;;;;;;;;;;;
  101.  
  102.  
  103. include 'gui.inc'
  104.  
  105. include 'emu.inc'
  106.  
  107. include 'utils.inc'
  108.  
  109. include 'data.inc'
  110.         rb      4096 ; reserve for main thread stack
  111. align 16
  112. _stacktop:
  113.  
  114. _mem:
  115.