comparison src/main.c @ 26:083347ccd508

Implemented vblank interrupts and fixed a bug in exception vector address calculation
author Michael Pavone <pavone@retrodev.com>
date Fri, 01 Apr 2016 21:34:38 -0700
parents fb14515266f4
children c677507682e3
comparison
equal deleted inserted replaced
25:fb14515266f4 26:083347ccd508
132 timer_run(&system->timer, context->cycles); 132 timer_run(&system->timer, context->cycles);
133 next = timer_next_interrupt(&system->timer); 133 next = timer_next_interrupt(&system->timer);
134 } 134 }
135 if (mask & 2) { 135 if (mask & 2) {
136 vdp_run(&system->video, context->cycles); 136 vdp_run(&system->video, context->cycles);
137 //TODO: VBlank interrupt 137 uint32_t vnext = vdp_next_interrupt(&system->video);
138 if (vnext < next) {
139 next = vnext;
140 }
138 } 141 }
139 return next; 142 return next;
140 } 143 }
141 144
142 uint8_t get_current_interrupts(cpu *context) 145 uint8_t get_current_interrupts(cpu *context)
146 uint8_t bits = 0; 149 uint8_t bits = 0;
147 if (system->timer.pending) { 150 if (system->timer.pending) {
148 bits |= 1; 151 bits |= 1;
149 } 152 }
150 vdp_run(&system->video, context->cycles); 153 vdp_run(&system->video, context->cycles);
151 //TODO: VBlank interrupt 154 if (vdp_interrupt_pending(&system->video)) {
155 bits |= 2;
156 }
152 return bits; 157 return bits;
153 } 158 }
154 159
155 void ack_interrupt(cpu *context, int which) 160 void ack_interrupt(cpu *context, int which)
156 { 161 {
157 console *system = context->system; 162 console *system = context->system;
158 if (which == 0) { 163 if (which == 0) {
159 timer_run(&system->timer, context->cycles); 164 timer_run(&system->timer, context->cycles);
160 system->timer.pending = 0; 165 system->timer.pending = 0;
161 } 166 } else {
162 //TODO: VBlank interrupt 167 vdp_ack_interrupt(&system->video);
168 }
163 } 169 }
164 170
165 memory_region regions[] = { 171 memory_region regions[] = {
166 {rom, 0, sizeof(rom)-1, MEM_READ}, 172 {rom, 0, sizeof(rom)-1, MEM_READ},
167 {ram, sizeof(rom), sizeof(rom)-1+sizeof(ram), MEM_READ}, 173 {ram, sizeof(rom), sizeof(rom)-1+sizeof(ram), MEM_READ},