-
Notifications
You must be signed in to change notification settings - Fork 11
/
audiomix.c
138 lines (107 loc) · 2.92 KB
/
audiomix.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
Based on mega65-fdisk program as a starting point.
*/
#include <stdio.h>
#include <string.h>
#include "freezer.h"
#include "freezer_common.h"
#include "fdisk_hal.h"
#include "fdisk_memory.h"
#include "fdisk_screen.h"
#include "fdisk_fat32.h"
void setup_menu_screen(void)
{
POKE(0xD018U, 0x15); // upper case
// NTSC 60Hz mode for monitor compatibility?
// POKE(0xD06FU, 0x80);
// Reset border widths
POKE(0xD05CU, 80);
POKE(0xD05DU, 0xC0);
// No sprites
POKE(0xD015U, 0x00);
// Move screen to SCREEN_ADDRESS
POKE(0xD018U, (((CHARSET_ADDRESS - 0x8000U) >> 11) << 1) + (((SCREEN_ADDRESS - 0x8000U) >> 10) << 4));
POKE(0xDD00U, (PEEK(0xDD00U) & 0xfc) | 0x01);
// 16-bit text mode with full colour for chars >$FF
// (which we will use for showing the thumbnail)
POKE(0xD054U, (PEEK(0xD054) & 0xa8) | 0x05);
POKE(0xD058U, 80);
POKE(0xD059U, 0); // 80 bytes per row
// Fill colour RAM with a value that won't cause problems in Super-Extended Attribute Mode
lfill(0xff80000U, 1, 2000);
}
static unsigned short i;
struct process_descriptor_t process_descriptor;
// Left/right do left/right
// fire = F3
// down = disk menu
// up = toggle PAL/NTSC ?
unsigned char joy_to_key[32] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xF3, // With fire pressed
0, 0, 0, 0, 0, 0, 0, 0x1d, 0, 0, 0, 0x9d, 0, 'd', 'v', 0 // without fire
};
#ifdef WITH_TOUCH
unsigned char touch_keys[2][9] = { { 0xF3, 0x00, 'c', 'r', 'f', 0x00, 'm', 'a', 'd' },
{ 0xF7, 0x00, 'j', 't', 'v', 0x00, 'e', 'k', 'x' } };
unsigned short x;
unsigned short y;
unsigned char last_touch = 0;
unsigned char last_x;
void poll_touch_panel(void)
{
if (PEEK(0xD6B0U) & 1) {
x = PEEK(0xD6B9) + ((PEEK(0xD6BB) & 0x03) << 8);
y = PEEK(0xD6BA) + ((PEEK(0xD6BB) & 0x30) << 4);
x = x >> 4;
y = y >> 4;
}
else {
x = 0;
y = 0;
}
}
#endif
#ifdef __CC65__
void main(void)
#else
int main(int argc, char** argv)
#endif
{
#ifdef __CC65__
mega65_fast();
#endif
// Disable interrupts and interrupt sources
__asm__("sei");
POKE(0xDC0DU, 0x7F);
POKE(0xDD0DU, 0x7F);
POKE(0xD01AU, 0x00);
// XXX add missing C65 AND M65 peripherals
// C65 UART, ethernet etc
// Bank out BASIC ROM, leave KERNAL and IO in
POKE(0x00, 0x3F);
POKE(0x01, 0x36);
// No decimal mode!
__asm__("cld");
// Enable extended attributes so we can use reverse
POKE(0xD031U, PEEK(0xD031U) | 0x20);
// Correct horizontal scaling
POKE(0xD05AU, 0x78);
// Silence SIDs
POKE(0xD418U, 0);
POKE(0xD438U, 0);
set_palette();
// Now find the start sector of the slot, and make a copy for safe keeping
slot_number = 0;
find_freeze_slot_start_sector(slot_number);
freeze_slot_start_sector = *(uint32_t*)0xD681U;
// SD or SDHC card?
if (PEEK(0xD680U) & 0x10)
sdhc_card = 1;
else
sdhc_card = 0;
setup_menu_screen();
request_freeze_region_list();
do_audio_mixer();
mega65_dos_exechelper("FREEZER.M65");
return;
}