4 This is a SAF (smallabstractfish) implementation of the game front end.
6 by Miloslav Ciz (drummyfish), 2020
8 Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
9 plus a waiver of all other intellectual property. The goal of this work is
10 be and remain completely in the public domain forever, available for any use
14 #define SAF_PROGRAM_NAME "Anarch"
15 #define SAF_PLATFORM_SDL2
19 #if SAF_PLATFORM_HARWARD
24 #define SFG_DIMINISH_SPRITES 1
25 #define SFG_RAYCASTING_MAX_HITS 7
26 #define SFG_CAN_EXIT 1
28 #define SFG_SCREEN_RESOLUTION_X SAF_SCREEN_WIDTH
29 #define SFG_SCREEN_RESOLUTION_Y SAF_SCREEN_HEIGHT
31 #define SFG_DITHERED_SHADOW 1
37 void SFG_setPixel(uint16_t x
, uint16_t y
, uint8_t colorIndex
)
39 SAF_drawPixel(x
,y
,palette
[colorIndex
]);
42 uint32_t SFG_getTimeMs(void)
47 void SFG_sleepMs(uint16_t timeMs
)
51 int8_t SFG_keyPressed(uint8_t key
)
55 case SFG_KEY_UP
: return SAF_buttonPressed(SAF_BUTTON_UP
); break;
56 case SFG_KEY_DOWN
: return SAF_buttonPressed(SAF_BUTTON_DOWN
); break;
57 case SFG_KEY_RIGHT
: return SAF_buttonPressed(SAF_BUTTON_RIGHT
); break;
58 case SFG_KEY_LEFT
: return SAF_buttonPressed(SAF_BUTTON_LEFT
); break;
59 case SFG_KEY_A
: return SAF_buttonPressed(SAF_BUTTON_A
); break;
60 case SFG_KEY_B
: return SAF_buttonPressed(SAF_BUTTON_B
); break;
61 case SFG_KEY_C
: return SAF_buttonPressed(SAF_BUTTON_C
); break;
62 default: return 0; break;
66 void SFG_getMouseOffset(int16_t *x
, int16_t *y
)
70 void SFG_setMusic(uint8_t value
)
74 void SFG_save(uint8_t data
[SFG_SAVE_SIZE
])
76 for (uint8_t i
= 0; i
< SFG_SAVE_SIZE
; ++i
)
80 void SFG_processEvent(uint8_t event
, uint8_t data
)
84 uint8_t SFG_load(uint8_t data
[SFG_SAVE_SIZE
])
86 for (uint8_t i
= 0; i
< SFG_SAVE_SIZE
; ++i
)
87 data
[i
] = SAF_load(i
);
92 void SFG_playSound(uint8_t soundIndex
, uint8_t volume
)
96 case 0: SAF_playSound(SAF_SOUND_BUMP
); break;
97 case 1: SAF_playSound(SAF_SOUND_CLICK
); break;
98 case 2: SAF_playSound(SAF_SOUND_BOOM
); break;
99 case 3: SAF_playSound(SAF_SOUND_CLICK
); break;
100 case 4: SAF_playSound(SAF_SOUND_BUMP
); break;
101 case 5: SAF_playSound(SAF_SOUND_BEEP
); break;
108 for (uint16_t i
= 0; i
< 256; ++i
)
110 uint16_t c
= paletteRGB565
[i
];
117 palette
[i
] = SAF_colorFromRGB(r
,g
,b
);
123 uint8_t SAF_loop(void)
125 return SFG_mainLoopBody();