Changeset 3c30832 in buchla-emu
- Timestamp:
- 07/23/2017 08:57:53 PM (7 years ago)
- Branches:
- master
- Children:
- 375f7fb
- Parents:
- 8e1b163
- Location:
- emu
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/all.h
r8e1b163 r3c30832 72 72 extern void fpu_init(void); 73 73 extern void fpu_quit(void); 74 extern voidfpu_exec(void);74 extern bool fpu_exec(void); 75 75 extern uint32_t fpu_read(uint32_t off, int32_t sz); 76 76 extern void fpu_write(uint32_t off, int32_t sz, uint32_t val); … … 78 78 extern void vid_init(void); 79 79 extern void vid_quit(void); 80 extern voidvid_exec(void);80 extern bool vid_exec(void); 81 81 extern uint32_t vid_read(uint32_t off, int32_t sz); 82 82 extern void vid_write(uint32_t off, int32_t sz, uint32_t val); … … 84 84 extern void tim_init(void); 85 85 extern void tim_quit(void); 86 extern voidtim_exec(void);86 extern bool tim_exec(void); 87 87 extern uint32_t tim_read(uint32_t off, int32_t sz); 88 88 extern void tim_write(uint32_t off, int32_t sz, uint32_t val); … … 90 90 extern void lcd_init(void); 91 91 extern void lcd_quit(void); 92 extern voidlcd_exec(void);92 extern bool lcd_exec(void); 93 93 extern uint32_t lcd_read(uint32_t off, int32_t sz); 94 94 extern void lcd_write(uint32_t off, int32_t sz, uint32_t val); … … 96 96 extern void ser_init(void); 97 97 extern void ser_quit(void); 98 extern voidser_exec(void);98 extern bool ser_exec(void); 99 99 extern uint32_t ser_read(uint32_t off, int32_t sz); 100 100 extern void ser_write(uint32_t off, int32_t sz, uint32_t val); … … 105 105 extern void mid_init(void); 106 106 extern void mid_quit(void); 107 extern voidmid_exec(void);107 extern bool mid_exec(void); 108 108 extern uint32_t mid_read(uint32_t off, int32_t sz); 109 109 extern void mid_write(uint32_t off, int32_t sz, uint32_t val); … … 111 111 extern void fdd_init(void); 112 112 extern void fdd_quit(void); 113 extern voidfdd_exec(void);113 extern bool fdd_exec(void); 114 114 extern uint32_t fdd_read(uint32_t off, int32_t sz); 115 115 extern void fdd_write(uint32_t off, int32_t sz, uint32_t val); … … 117 117 extern void snd_init(void); 118 118 extern void snd_quit(void); 119 extern voidsnd_exec(void);119 extern bool snd_exec(void); 120 120 extern uint32_t snd_read(uint32_t off, int32_t sz); 121 121 extern void snd_write(uint32_t off, int32_t sz, uint32_t val); … … 123 123 extern void led_init(void); 124 124 extern void led_quit(void); 125 extern voidled_exec(void);125 extern bool led_exec(void); 126 126 extern uint32_t led_read(uint32_t off, int32_t sz); 127 127 extern void led_write(uint32_t off, int32_t sz, uint32_t val); … … 129 129 extern void kbd_init(void); 130 130 extern void kbd_quit(void); 131 extern voidkbd_exec(void);131 extern bool kbd_exec(void); 132 132 extern uint32_t kbd_read(uint32_t off, int32_t sz); 133 133 extern void kbd_write(uint32_t off, int32_t sz, uint32_t val); -
emu/cpu.c
r8e1b163 r3c30832 37 37 typedef void (*hw_init_t)(void); 38 38 typedef void (*hw_quit_t)(void); 39 typedef void(*hw_exec_t)(void);39 typedef bool (*hw_exec_t)(void); 40 40 typedef uint32_t (*hw_read_t)(uint32_t off, int32_t sz); 41 41 typedef void (*hw_write_t)(uint32_t off, int32_t sz, uint32_t val); … … 44 44 uint32_t addr_beg; 45 45 uint32_t addr_end; 46 uint32_t irq; 46 47 hw_init_t init; 47 48 hw_quit_t quit; … … 67 68 68 69 static hw_t hw_map[] = { 69 { 0x180000, 0x200000, fpu_init, fpu_quit, fpu_exec, fpu_read, fpu_write },70 { 0x200000, 0x280000, vid_init, vid_quit, vid_exec, vid_read, vid_write },71 { 0x3a0001, 0x3a4001, tim_init, tim_quit, tim_exec, tim_read, tim_write },72 { 0x3a4001, 0x3a8001, lcd_init, lcd_quit, lcd_exec, lcd_read, lcd_write },73 { 0x3a8001, 0x3ac001, ser_init, ser_quit, ser_exec, ser_read, ser_write },74 { 0x3ac001, 0x3b0001, mid_init, mid_quit, mid_exec, mid_read, mid_write },75 { 0x3b0001, 0x3b4001, fdd_init, fdd_quit, fdd_exec, fdd_read, fdd_write },76 { 0x3b4001, 0x3b8001, snd_init, snd_quit, snd_exec, snd_read, snd_write },77 { 0x3b8001, 0x3bc001, led_init, led_quit, led_exec, led_read, led_write },78 { 0x3bc001, 0x3c0001, kbd_init, kbd_quit, kbd_exec, kbd_read, kbd_write }70 { 0x180000, 0x200000, 0, fpu_init, fpu_quit, fpu_exec, fpu_read, fpu_write }, 71 { 0x200000, 0x280000, 0, vid_init, vid_quit, vid_exec, vid_read, vid_write }, 72 { 0x3a0001, 0x3a4001, 0, tim_init, tim_quit, tim_exec, tim_read, tim_write }, 73 { 0x3a4001, 0x3a8001, 0, lcd_init, lcd_quit, lcd_exec, lcd_read, lcd_write }, 74 { 0x3a8001, 0x3ac001, 5, ser_init, ser_quit, ser_exec, ser_read, ser_write }, 75 { 0x3ac001, 0x3b0001, 0, mid_init, mid_quit, mid_exec, mid_read, mid_write }, 76 { 0x3b0001, 0x3b4001, 0, fdd_init, fdd_quit, fdd_exec, fdd_read, fdd_write }, 77 { 0x3b4001, 0x3b8001, 0, snd_init, snd_quit, snd_exec, snd_read, snd_write }, 78 { 0x3b8001, 0x3bc001, 0, led_init, led_quit, led_exec, led_read, led_write }, 79 { 0x3bc001, 0x3c0001, 0, kbd_init, kbd_quit, kbd_exec, kbd_read, kbd_write } 79 80 }; 80 81 … … 108 109 } 109 110 110 static void hw_exec(void) 111 { 111 static uint32_t hw_exec(void) 112 { 113 uint32_t irq = 0; 114 112 115 for (int32_t i = 0; i < ARRAY_COUNT(hw_map); ++i) { 113 hw_map[i].exec(); 114 } 116 if (hw_map[i].exec() && hw_map[i].irq > irq) { 117 irq = hw_map[i].irq; 118 } 119 } 120 121 return irq; 115 122 } 116 123 … … 629 636 630 637 m68k_execute(CPU_FREQ / PER_SEC); 631 hw_exec(); 638 uint32_t irq = hw_exec(); 639 640 if (irq > 0) { 641 ver2("irq %u", irq); 642 } 643 644 m68k_set_irq(irq); 632 645 633 646 SDL_Event ev; -
emu/fdd.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidfdd_exec(void)36 bool fdd_exec(void) 37 37 { 38 38 ver3("fdd exec"); 39 return false; 39 40 } 40 41 -
emu/fpu.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidfpu_exec(void)36 bool fpu_exec(void) 37 37 { 38 38 ver3("fpu exec"); 39 return false; 39 40 } 40 41 -
emu/kbd.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidkbd_exec(void)36 bool kbd_exec(void) 37 37 { 38 38 ver3("kbd exec"); 39 return false; 39 40 } 40 41 -
emu/lcd.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidlcd_exec(void)36 bool lcd_exec(void) 37 37 { 38 38 ver3("lcd exec"); 39 return false; 39 40 } 40 41 -
emu/led.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidled_exec(void)36 bool led_exec(void) 37 37 { 38 38 ver3("led exec"); 39 return false; 39 40 } 40 41 -
emu/mid.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidmid_exec(void)36 bool mid_exec(void) 37 37 { 38 38 ver3("mid exec"); 39 return false; 39 40 } 40 41 -
emu/ser.c
r8e1b163 r3c30832 31 31 #define CON_FONT "ttf/vera-sans-mono.ttf" 32 32 33 #define REG_IER_ISR 0 34 #define REG_CFR_SR 1 35 #define REG_CDR_TBR 2 36 #define REG_TDR_RDR 3 37 38 typedef struct { 39 bool irq; 40 uint8_t rdr; 41 } state_t; 42 33 43 int32_t ser_verbose = 0; 44 45 static state_t state[] = { 46 { .irq = false, .rdr = 0x00 }, 47 { .irq = false, .rdr = 0x00 } 48 }; 34 49 35 50 static uint8_t mem[CON_H][CON_W + 1]; … … 42 57 43 58 static int32_t cur_x = 0, cur_y = 0; 59 60 static void out(int32_t un, uint8_t c) 61 { 62 state[un].irq = true; 63 state[un].rdr = c; 64 } 44 65 45 66 static void update(void) … … 173 194 switch (ev->keysym.sym) { 174 195 case SDLK_BACKSPACE: 175 echo('\b');196 out(1, '\b'); 176 197 break; 177 198 178 199 case SDLK_RETURN: 179 echo('\r'); 180 echo('\n'); 200 out(1, '\r'); 181 201 break; 182 202 … … 184 204 if ((ev->keysym.mod & KMOD_CTRL) != 0 && 185 205 ev->keysym.sym >= SDLK_a && ev->keysym.sym <= SDLK_z) { 186 echo((uint8_t)(ev->keysym.sym - SDLK_a + 1));206 out(1, (uint8_t)(ev->keysym.sym - SDLK_a + 1)); 187 207 } 188 208 … … 194 214 { 195 215 for (int32_t i = 0; ev->text[i] != 0; ++i) { 196 echo((uint8_t)ev->text[i]);216 out(1, (uint8_t)ev->text[i]); 197 217 } 198 218 } … … 248 268 } 249 269 250 voidser_exec(void)270 bool ser_exec(void) 251 271 { 252 272 ver3("ser exec"); 273 return state[0].irq || state[1].irq; 253 274 } 254 275 … … 256 277 { 257 278 ver2("ser rd %u:%d", off, sz * 8); 258 return 0; 279 280 if (sz != 1 || off > 7) { 281 fail("invalid ser rd %u:%d", off, sz * 8); 282 } 283 284 int32_t rg = (int32_t)(off % 4); 285 int32_t un = (int32_t)(off / 4); 286 287 uint32_t rv; 288 289 switch (rg) { 290 case REG_IER_ISR: 291 rv = (uint32_t)(0xc0 | (state[un].irq ? 0x01 : 0x00)); 292 ver2("ISR[%d] 0x%02x", un, rv); 293 break; 294 295 case REG_TDR_RDR: 296 rv = state[un].rdr; 297 state[un].irq = false; 298 ver2("RDR[%d] 0x%02x", un, rv); 299 break; 300 301 default: 302 rv = 0x00; 303 break; 304 } 305 306 return rv; 259 307 } 260 308 … … 262 310 { 263 311 ver2("ser wr %u:%d 0x%0*x", off, sz * 8, sz * 2, val); 264 } 312 313 if (sz != 1 || off > 7) { 314 fail("invalid ser wr %u:%d", off, sz * 8); 315 } 316 317 int32_t rg = (int32_t)(off % 4); 318 int32_t un = (int32_t)(off / 4); 319 320 switch (rg) { 321 case REG_TDR_RDR: 322 ver2("TDR[%d] 0x%02x", un, val); 323 echo((uint8_t)val); 324 break; 325 326 default: 327 break; 328 } 329 } -
emu/snd.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidsnd_exec(void)36 bool snd_exec(void) 37 37 { 38 38 ver3("snd exec"); 39 return false; 39 40 } 40 41 -
emu/tim.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidtim_exec(void)36 bool tim_exec(void) 37 37 { 38 38 ver3("tim exec"); 39 return false; 39 40 } 40 41 -
emu/vid.c
r8e1b163 r3c30832 34 34 } 35 35 36 voidvid_exec(void)36 bool vid_exec(void) 37 37 { 38 38 ver3("vid exec"); 39 return false; 39 40 } 40 41
Note:
See TracChangeset
for help on using the changeset viewer.