Alchemy
Loading...
Searching...
No Matches

scroll_initialize_hblank_dma.h

Go to the documentation of this file.
1#include "mem.h"
2#include "engine_call.h"
3#include "dma.h"
4#include "system.h"
6#include "scroll.h"
7#include "io_reg.h"
8
9// The Lemurian ship: the ripple of the water, a wave in each axis of the
10// background's scrolling, changed line by line in the horizontal blank.
11
12static __inline__ void WaitDma(volatile u32 *channel) {
13 while (channel[2] & 0x80000000) {
14 }
15}
16
17/// Starts the ripple: its work (heap block 34) holds the mode and, for x and y,
18/// the wave's frequency, its step each frame and its amplitude; two scene
19/// callbacks build each frame's table of line offsets and sends it by DMA in
20/// the horizontal blank.
21void DisplayScroll_InitializeHBlankDma(s32 mode, s32 freqX, s32 stepX, s32 ampX,
22 s32 freqY, s32 stepY, s32 ampY) {
23 struct DisplayScrollWork *work;
24
25 work = Runtime_AllocateBlock(34, 0xf20);
26 Dma_Fill32(0, work, 0xf20);
28 work->mode = mode;
29 work->freqX = freqX;
30 work->freqY = freqY;
31 work->ampX = ampX;
32 work->ampY = ampY;
33 work->stepX = stepX;
34 work->stepY = stepY;
38}
The task scheduler: tasks, their order and the scheduler's state.
DMA channel registers, and the DMA and CPU fills.
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
Definition dma.h:30
The engine call layer: one typed inline for each of the thirteen main-image routines below that the s...
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
@ TASK_PRIORITY_SCENE
Definition field_event.h:40
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
Definition heap.c:80
The hardware's I/O registers and their bits, as pret names them.
#define REG_DMA3
Definition io_reg.h:153
The heaps: allocating and freeing blocks.
static __inline__ void WaitDma(struct DmaRegisters volatile *channel)
Definition save_state.h:96
The display scroll work, the HBlank scroll work and its wave.
void DisplayScroll_InitializeHBlankDma(s32 mode, s32 freqX, s32 stepX, s32 ampX, s32 freqY, s32 stepY, s32 ampY)
Starts the ripple: its work (heap block 34) holds the mode and, for x and y, the wave's frequency,...
The wavy background's work: two pages of BG1 to BG3 scroll offsets for each of the 160 scanlines,...
Definition scroll.h:12
u8 mode
set at the start; not read by name
Definition scroll.h:15
s32 freqX
phase per frame and per BG3 row, 16.16 wave table entries
Definition scroll.h:18
s32 stepY
16.16 wave table entries a scanline, 256 a cycle
Definition scroll.h:21
s32 ampX
16.16 scale on the sine entry, which is then divided by 256
Definition scroll.h:22
s32 ampY
16.16 scale on the sine entry, which is then divided by 256
Definition scroll.h:23
s32 freqY
phase per frame and per BG3 row, 16.16 wave table entries
Definition scroll.h:19
s32 stepX
16.16 wave table entries a scanline, 256 a cycle
Definition scroll.h:20
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
void DisplayScroll_ArmHBlankDma(void)
Scheduler callback for the wavy background: restarts DMA 0 each frame to copy the current page's BG1 ...
Definition wave_scroll.c:11
void DisplayScroll_BuildAndSwapHBlankPage(void)
Scheduler callback for the wavy background: fills the hidden page with each scanline's BG3,...
Definition wave_scroll.c:44