Mercurial > repos > simple16
annotate src/main.c @ 24:4c9dbfa30a66
Implemented audio
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 31 Mar 2016 00:07:37 -0700 |
parents | 04fc17376999 |
children | fb14515266f4 |
rev | line source |
---|---|
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <stdint.h> |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdio.h> |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include <stdlib.h> |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <string.h> |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "cpu.h" |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
6 #include "vdp.h" |
24 | 7 #include "audio.h" |
11
04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
Michael Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
8 #include "system.h" |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
10 #define CYCLES_PER_FRAME (832*262) |
24 | 11 #define MASTER_CLOCK 13056000 |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 uint8_t rom[48 * 1024]; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 uint8_t ram[16 * 1024]; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 enum { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 PORT_CONTROLLER_1, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 PORT_CONTROLLER_2, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 PORT_CONTROLLER_3, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 PORT_CONTROLLER_4, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 PORT_FREQUENCY_A, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 PORT_FREQUENCY_B, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 PORT_FREQUENCY_C, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 PORT_FREQUENCY_D, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 PORT_VOLUME_AB, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 PORT_VOLUME_CD, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 PORT_TIMER, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 PORT_SERIAL, |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
29 PORT_VERTICAL, |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
30 PORT_HORIZONTAL, |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
31 PORT_VRAM_ADDRESS, |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
32 PORT_VRAM_DATA |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 }; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
35 typedef struct { |
24 | 36 cpu *proc; |
37 vdp video; | |
38 audio *audio; | |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
39 } console; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
40 |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 void debug_port_write(cpu *context, uint8_t port, uint16_t value) |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 putchar(value); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 uint16_t debug_port_read(cpu *context, uint8_t port) |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 return getchar(); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
51 void vertical_port_write(cpu *context, uint8_t port, uint16_t value) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
52 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
53 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
54 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
55 system->video.vscroll = value; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
56 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
57 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
58 uint16_t vertical_port_read(cpu *context, uint8_t port) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
59 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
60 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
61 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
62 return system->video.vcounter; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
63 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
64 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
65 void horizontal_port_write(cpu *context, uint8_t port, uint16_t value) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
66 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
67 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
68 vdp_run(&system->video, context->cycles); |
19
04fc17376999
Sort of working tile rendering and tile test ROM
Michael Pavone <pavone@retrodev.com>
parents:
16
diff
changeset
|
69 vdp_write_hscroll(&system->video, value); |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
70 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
71 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
72 uint16_t horizontal_port_read(cpu *context, uint8_t port) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
73 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
74 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
75 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
76 return system->video.hcounter; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
77 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
78 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
79 void address_port_write(cpu *context, uint8_t port, uint16_t value) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
80 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
81 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
82 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
83 vdp_write_address(&system->video, value); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
84 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
85 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
86 uint16_t address_port_read(cpu *context, uint8_t port) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
87 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
88 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
89 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
90 return system->video.status; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
91 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
92 |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
93 void data_port_write(cpu *context, uint8_t port, uint16_t value) |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
94 { |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
95 console *system = context->system; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
96 vdp_run(&system->video, context->cycles); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
97 vdp_write_data(&system->video, value); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
98 } |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
99 |
24 | 100 void frequency_port_write(cpu *context, uint8_t port, uint16_t value) |
101 { | |
102 console *system = context->system; | |
103 audio_run(system->audio, context->cycles); | |
104 audio_write_freq(system->audio, port - PORT_FREQUENCY_A, value); | |
105 } | |
106 | |
107 void volume_port_write(cpu *context, uint8_t port, uint16_t value) | |
108 { | |
109 console *system = context->system; | |
110 audio_run(system->audio, context->cycles); | |
111 audio_write_vol(system->audio, port - PORT_VOLUME_AB, value); | |
112 } | |
113 | |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 memory_region regions[] = { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 {rom, 0, sizeof(rom)-1, MEM_READ}, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 {ram, sizeof(rom), sizeof(rom)-1+sizeof(ram), MEM_READ}, |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 }; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
119 void run_console(console *context) |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 for(;;) |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 { |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
123 run_cpu(context->proc, CYCLES_PER_FRAME); |
24 | 124 audio_run(context->audio, CYCLES_PER_FRAME); |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
125 vdp_run(&context->video, CYCLES_PER_FRAME); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
126 context->proc->cycles -= CYCLES_PER_FRAME; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
127 context->video.cycles -= CYCLES_PER_FRAME; |
24 | 128 context->audio->cycles -= CYCLES_PER_FRAME; |
16
ae58e7c3c328
Poll events regularly to avoid unresponsive app warnings. Handle quit event
Michael Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
129 system_poll_events(); |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 int main(int argc, char **argv) |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 if (argc < 2) { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 fputs("usage: s16 FILE\n", stderr); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 return 1; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 FILE *f = fopen(argv[1], "rb"); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 if (!f) { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 fprintf(stderr, "Failed to open %s for reading\n", argv[1]); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 return 1; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 } |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 size_t read; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 if ((read = fread(rom, 1, sizeof(rom), f)) < sizeof(rom)) { |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 memset(rom + read, 0xFF, sizeof(rom)-read); |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 } |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
149 console context; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
150 context.proc = alloc_cpu(10, sizeof(regions)/sizeof(memory_region), regions); |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
151 context.proc->system = &context; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
152 vdp_init(&context.video, 2); |
24 | 153 context.proc->port_handlers[PORT_FREQUENCY_A].write = frequency_port_write; |
154 context.proc->port_handlers[PORT_FREQUENCY_B].write = frequency_port_write; | |
155 context.proc->port_handlers[PORT_FREQUENCY_C].write = frequency_port_write; | |
156 context.proc->port_handlers[PORT_FREQUENCY_D].write = frequency_port_write; | |
157 context.proc->port_handlers[PORT_VOLUME_AB].write = volume_port_write; | |
158 context.proc->port_handlers[PORT_VOLUME_CD].write = volume_port_write; | |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
159 context.proc->port_handlers[PORT_SERIAL].write = debug_port_write; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
160 context.proc->port_handlers[PORT_SERIAL].read = debug_port_read; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
161 context.proc->port_handlers[PORT_VERTICAL].write = vertical_port_write; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
162 context.proc->port_handlers[PORT_VERTICAL].read = vertical_port_read; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
163 context.proc->port_handlers[PORT_HORIZONTAL].write = horizontal_port_write; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
164 context.proc->port_handlers[PORT_HORIZONTAL].read = horizontal_port_read; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
165 context.proc->port_handlers[PORT_VRAM_ADDRESS].write = address_port_write; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
166 context.proc->port_handlers[PORT_VRAM_ADDRESS].read = address_port_read; |
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
167 context.proc->port_handlers[PORT_VRAM_DATA].write = data_port_write; |
11
04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
Michael Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
168 |
24 | 169 if (!system_init(640, 480, 48000)) { |
11
04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
Michael Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
170 return 1; |
04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
Michael Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
171 } |
04d8efe7a1f0
Initial stab at video output and background color rendering. Fixed address decoding in address port write handler.
Michael Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
172 |
24 | 173 context.audio = alloc_audio(MASTER_CLOCK, 17, system_sample_rate(), system_buffer_size()); |
174 | |
8
5176efdda5ae
Initial work on VDP emulation
Michael Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
175 run_console(&context); |
0
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 return 0; |
7e44f7d5810b
Initial commit. CPU working well enough for simple hello world program.
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 } |