Use the volatile keyword with all inline assembly to make sure the optimizer does not discard any of it.
This commit is contained in:
parent
204e9c119a
commit
70189e1567
Binary file not shown.
|
@ -74,7 +74,7 @@ static char displayBuffer[] =
|
|||
static void playSound(int8_t freq, int8_t duration)
|
||||
{
|
||||
while (duration > 0) {
|
||||
asm ("STA %w", 0xc030);
|
||||
asm volatile ("STA %w", 0xc030);
|
||||
while (freq > 0) {
|
||||
freq--;
|
||||
}
|
||||
|
@ -365,13 +365,13 @@ static tAction getNextAction(void)
|
|||
void textMode(void)
|
||||
{
|
||||
clrscr();
|
||||
asm ("STA %w", 0xc051);
|
||||
asm volatile ("STA %w", 0xc051);
|
||||
}
|
||||
|
||||
|
||||
void graphicsMode(void)
|
||||
{
|
||||
asm ("STA %w", 0xc050);
|
||||
asm volatile ("STA %w", 0xc050);
|
||||
}
|
||||
|
||||
|
||||
|
@ -479,7 +479,7 @@ void redrawUI(void)
|
|||
}
|
||||
|
||||
// Mixed text and graphics mode
|
||||
asm ("STA %w", 0xc053);
|
||||
asm volatile ("STA %w", 0xc053);
|
||||
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
printState();
|
||||
}
|
||||
|
|
|
@ -30,11 +30,11 @@ static uint8_t joystickTemp;
|
|||
static bool isButtonPressed(int8_t buttonNum)
|
||||
{
|
||||
if (buttonNum) {
|
||||
__asm__("LDA %w", BTN1);
|
||||
__asm__("STA %v", joystickTemp);
|
||||
__asm__ volatile("LDA %w", BTN1);
|
||||
__asm__ volatile("STA %v", joystickTemp);
|
||||
} else {
|
||||
__asm__("LDA %w", BTN0);
|
||||
__asm__("STA %v", joystickTemp);
|
||||
__asm__ volatile("LDA %w", BTN0);
|
||||
__asm__ volatile("STA %v", joystickTemp);
|
||||
}
|
||||
return ((joystickTemp > 127) ? true : false);
|
||||
}
|
||||
|
@ -42,22 +42,22 @@ static bool isButtonPressed(int8_t buttonNum)
|
|||
|
||||
static uint8_t joystickLeftRight(void)
|
||||
{
|
||||
__asm__("BIT %w", ROM_SWITCH);
|
||||
__asm__("LDX #0");
|
||||
__asm__("JSR %w", PREAD);
|
||||
__asm__("STY %v", joystickTemp);
|
||||
__asm__("BIT %w", RAM_SWITCH);
|
||||
__asm__ volatile("BIT %w", ROM_SWITCH);
|
||||
__asm__ volatile("LDX #0");
|
||||
__asm__ volatile("JSR %w", PREAD);
|
||||
__asm__ volatile("STY %v", joystickTemp);
|
||||
__asm__ volatile("BIT %w", RAM_SWITCH);
|
||||
return joystickTemp;
|
||||
}
|
||||
|
||||
|
||||
static uint8_t joystickUpDown(void)
|
||||
{
|
||||
__asm__("BIT %w", ROM_SWITCH);
|
||||
__asm__("LDX #1");
|
||||
__asm__("JSR %w", PREAD);
|
||||
__asm__("STY %v", joystickTemp);
|
||||
__asm__("BIT %w", RAM_SWITCH);
|
||||
__asm__ volatile("BIT %w", ROM_SWITCH);
|
||||
__asm__ volatile("LDX #1");
|
||||
__asm__ volatile("JSR %w", PREAD);
|
||||
__asm__ volatile("STY %v", joystickTemp);
|
||||
__asm__ volatile("BIT %w", RAM_SWITCH);
|
||||
return joystickTemp;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue