megadrive_test2
diff src/main.c @ 9:6ecf2f3ff05a
- better pad input handling
- switch between 28 and 30 vertical tiles by pressing C
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 24 Jun 2017 00:33:10 +0300 |
parents | 403367d5df5a |
children | ca7108a82867 |
line diff
1.1 --- a/src/main.c Thu Jun 22 07:44:48 2017 +0300 1.2 +++ b/src/main.c Sat Jun 24 00:33:10 2017 +0300 1.3 @@ -1,6 +1,8 @@ 1.4 #include <stdint.h> 1.5 #include "vdp.h" 1.6 #include "io.h" 1.7 +#include "pad.h" 1.8 +#include "intr.h" 1.9 #include "tun_data.h" 1.10 1.11 #define NAMETAB_A 6 1.12 @@ -25,8 +27,6 @@ 1.13 VDP_PACK_RGB(7, 0, 3) /* 15: fixed */ 1.14 }; 1.15 1.16 -static int running = 1; 1.17 - 1.18 1.19 int main(void) 1.20 { 1.21 @@ -42,7 +42,6 @@ 1.22 for(i=0; i<16; i++) { 1.23 VDP_PORT_DATA = pal[i]; 1.24 } 1.25 - vdp_set_bgcolor(0, 0); 1.26 1.27 for(i=0; i<tun_xtiles * tun_ytiles; i++) { 1.28 load_pattern(i, tun_tiles[i]); 1.29 @@ -61,10 +60,12 @@ 1.30 vdp_enable_vintr(); 1.31 1.32 for(;;) { 1.33 - uint16_t bnstate = io_readpad(0); 1.34 + pad_update(0); 1.35 1.36 - if(bnstate & IO_PAD_START) { 1.37 - running = !running; 1.38 + if(pad_pressed(0, IO_PAD_C)) { 1.39 + disable_intr(); 1.40 + vdp_setreg(VDP_REG_MODE2, vdp_getreg(VDP_REG_MODE2) ^ VDP_MODE2_V30CELL); 1.41 + enable_intr(); 1.42 } 1.43 1.44 vdp_wait_vblank(); 1.45 @@ -101,8 +102,6 @@ 1.46 int idx = CYCLE_BEG; 1.47 uint16_t first; 1.48 1.49 - if(!running) return; 1.50 - 1.51 first = pal[idx]; 1.52 1.53 vdp_begin_palette(0, idx);