mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 14:19:28 +02:00
* NDS: updated the rtl, libnds and fixed the examples. Now it should work fine with devkitARM r26
- Removed (again) old libgba examples git-svn-id: trunk@13585 -
This commit is contained in:
parent
9a84dee059
commit
3f9327d340
22
.gitattributes
vendored
22
.gitattributes
vendored
@ -3106,26 +3106,6 @@ packages/libgbafpc/examples/audio/PlayBoyScout/Makefile.fpc svneol=native#text/p
|
||||
packages/libgbafpc/examples/audio/PlayBoyScout/PlayBoyScout.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/audio/PlayBoyScout/data/ScoutSplash.pcx -text
|
||||
packages/libgbafpc/examples/audio/PlayBoyScout/data/tune.bgf -text
|
||||
packages/libgbafpc/examples/devkitPro/audio/PlayBoyScout/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/audio/PlayBoyScout/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/audio/PlayBoyScout/PlayBoyScout.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/audio/PlayBoyScout/data/ScoutSplash.pcx -text svneol=unset#image/pcx
|
||||
packages/libgbafpc/examples/devkitPro/audio/PlayBoyScout/data/tune.bgf -text
|
||||
packages/libgbafpc/examples/devkitPro/graphics/PCXView/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/PCXView/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/PCXView/data/ScoutSplash.pcx -text svneol=unset#image/pcx
|
||||
packages/libgbafpc/examples/devkitPro/graphics/PCXView/data/splash.pcx -text svneol=unset#image/pcx
|
||||
packages/libgbafpc/examples/devkitPro/graphics/PCXView/pcx_view.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/SimpleBGScroll/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/SimpleBGScroll/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/SimpleBGScroll/SimpleBGScroll.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/SimpleBGScroll/data/r6502_portfont.bin -text
|
||||
packages/libgbafpc/examples/devkitPro/graphics/ansi_console/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/ansi_console/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/graphics/ansi_console/console.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/template/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/template/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/devkitPro/template/template.pp svneol=native#text/plain
|
||||
packages/libgbafpc/examples/graphics/Makefile svneol=native#text/plain
|
||||
packages/libgbafpc/examples/graphics/Makefile.fpc svneol=native#text/plain
|
||||
packages/libgbafpc/examples/graphics/PCXView/Makefile svneol=native#text/plain
|
||||
@ -6053,6 +6033,8 @@ rtl/nds/classes.pp svneol=native#text/plain
|
||||
rtl/nds/cprt07.as svneol=native#text/plain
|
||||
rtl/nds/cprt09.as svneol=native#text/plain
|
||||
rtl/nds/dos.pp svneol=native#text/plain
|
||||
rtl/nds/libc.inc svneol=native#text/plain
|
||||
rtl/nds/libch.inc svneol=native#text/plain
|
||||
rtl/nds/nds.inc svneol=native#text/plain
|
||||
rtl/nds/ndsbios.inc svneol=native#text/plain
|
||||
rtl/nds/ndsbiosh.inc svneol=native#text/plain
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,36 +0,0 @@
|
||||
#
|
||||
# Makefile.fpc for Free Pascal libgbafpc 2.x.y Examples
|
||||
#
|
||||
|
||||
[target]
|
||||
loaders=data/ScoutSplash.pcx data/tune.bgf
|
||||
programs=PlayBoyScout
|
||||
|
||||
[require]
|
||||
packages=libgbafpc
|
||||
tools=bin2s
|
||||
|
||||
[install]
|
||||
fpcpackage=y
|
||||
|
||||
[default]
|
||||
cpu=arm
|
||||
target=gba
|
||||
fpcdir=../../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf data/*.o data/*.s
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
||||
ifneq ($(BIN2S),)
|
||||
data/ScoutSplash.pcx.o:
|
||||
$(BIN2S) data/ScoutSplash.pcx > data/ScoutSplash.pcx.s
|
||||
$(AS) -o data/ScoutSplash.pcx.o data/ScoutSplash.pcx.s
|
||||
data/tune.bgf.o:
|
||||
$(BIN2S) data/tune.bgf > data/tune.bgf.s
|
||||
$(AS) -o data/tune.bgf.o data/tune.bgf.s
|
||||
endif
|
@ -1,73 +0,0 @@
|
||||
program PlayBoyScout;
|
||||
|
||||
{$l data/ScoutSplash.pcx.o}
|
||||
{$l data/tune.bgf.o}
|
||||
|
||||
uses
|
||||
ctypes, gba;
|
||||
|
||||
|
||||
var
|
||||
ScoutSplash_pcx: array [0..0] of cuint8; cvar; external;
|
||||
ScoutSplash_pcx_size: array [0..0] of cuint32; cvar; external;
|
||||
ScoutSplash_pcx_end: array [0..0] of cuint8; cvar; external;
|
||||
tune_bgf: array [0..0] of cuint8; cvar; external;
|
||||
tune_bgf_size: array [0..0] of cuint32; cvar; external;
|
||||
tune_bgf_end: array [0..0] of cuint8; cvar; external;
|
||||
|
||||
|
||||
PaletteBuffer: array [0..255] of u16;
|
||||
frame: cuint;
|
||||
nBSSongSize: cuint;
|
||||
|
||||
procedure VblankInterrupt();
|
||||
begin
|
||||
BoyScoutUpdateSong();
|
||||
frame := frame + 1;
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
// Set up the interrupt handlers
|
||||
irqInit();
|
||||
|
||||
// Initialize BoyScout
|
||||
BoyScoutInitialize();
|
||||
|
||||
// Get needed song memory
|
||||
nBSSongSize := BoyScoutGetNeededSongMemory(tune_bgf);
|
||||
|
||||
// Allocate and set BoyScout memory area
|
||||
BoyScoutSetMemoryArea(u32(GetMem(nBSSongSize)));
|
||||
|
||||
// Open song
|
||||
BoyScoutOpenSong(tune_bgf);
|
||||
|
||||
// Play song and loop
|
||||
BoyScoutPlaySong(1);
|
||||
|
||||
irqSet(IRQ_VBLANK, @VblankInterrupt);
|
||||
|
||||
// Enable Vblank Interrupt to allow VblankIntrWait
|
||||
irqEnable(IRQ_VBLANK);
|
||||
// Allow Interrupts
|
||||
REG_IME^ := 1;
|
||||
|
||||
SetMode( MODE_4 or BG2_ON ); // screen mode & background to display
|
||||
|
||||
DecodePCX(@ScoutSplash_pcx, pu16(VRAM), PaletteBuffer);
|
||||
|
||||
FadeToPalette( PaletteBuffer, 60);
|
||||
|
||||
|
||||
while true do
|
||||
VBlankIntrWait();
|
||||
|
||||
// This part will never be reached but just for completion
|
||||
// Free memory
|
||||
free(@BoyScoutGetMemoryArea);
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,34 +0,0 @@
|
||||
#
|
||||
# Makefile.fpc for Free Pascal libgbafpc 2.x.y Examples
|
||||
#
|
||||
|
||||
[target]
|
||||
loaders=$(DATA_FILES)
|
||||
programs=pcx_view
|
||||
|
||||
[require]
|
||||
packages=libgbafpc
|
||||
tools=bin2s
|
||||
|
||||
[install]
|
||||
fpcpackage=y
|
||||
|
||||
[default]
|
||||
cpu=arm
|
||||
target=gba
|
||||
fpcdir=../../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf data/*.o data/*.s
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
DATA_FILES=data/splash.pcx
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
||||
ifneq ($(BIN2S),)
|
||||
$(DATA_FILES).o:
|
||||
$(BIN2S) $(DATA_FILES) > $(DATA_FILES).s
|
||||
$(AS) -o $(DATA_FILES).o $(DATA_FILES).s
|
||||
endif
|
Binary file not shown.
Binary file not shown.
@ -1,46 +0,0 @@
|
||||
program pcx_view;
|
||||
|
||||
uses
|
||||
ctypes, gba;
|
||||
|
||||
{$l data/splash.pcx.o}
|
||||
|
||||
var
|
||||
PaletteBuffer: array [0..255] of cuint16;
|
||||
frame: cuint;
|
||||
|
||||
splash_pcx_end: array [0..0] of cuint8; cvar; external;
|
||||
splash_pcx: array [0..0] of cuint8; cvar; external;
|
||||
splash_pcx_size: array [0..0] of cuint32; cvar; external;
|
||||
|
||||
|
||||
procedure VblankInterrupt();
|
||||
begin
|
||||
frame := frame + 1;
|
||||
scanKeys();
|
||||
end;
|
||||
|
||||
|
||||
|
||||
begin
|
||||
// Set up the interrupt handlers
|
||||
irqInit();
|
||||
irqSet(IRQ_VBLANK, @VblankInterrupt);
|
||||
|
||||
// Enable Vblank Interrupt to allow VblankIntrWait
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
// Allow Interrupts
|
||||
REG_IME^ := 1;
|
||||
|
||||
SetMode(MODE_4 or BG2_ON); // screen mode & background to display
|
||||
|
||||
DecodePCX(@splash_pcx, pcuint16(VRAM), @PaletteBuffer);
|
||||
|
||||
FadeToPalette(PaletteBuffer, 60);
|
||||
|
||||
while true do
|
||||
VBlankIntrWait();
|
||||
end.
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,33 +0,0 @@
|
||||
#
|
||||
# Makefile.fpc for Free Pascal libgbafpc 2.x.y Examples
|
||||
#
|
||||
|
||||
[target]
|
||||
loaders=data/r6502_portfont.bin
|
||||
programs=SimpleBGScroll
|
||||
|
||||
[require]
|
||||
packages=libgbafpc
|
||||
tools=bin2s
|
||||
|
||||
[install]
|
||||
fpcpackage=y
|
||||
|
||||
[default]
|
||||
cpu=arm
|
||||
target=gba
|
||||
fpcdir=../../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf data/*.o data/*.s
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
||||
ifneq ($(BIN2S),)
|
||||
data/r6502_portfont.bin.o:
|
||||
$(BIN2S) data/r6502_portfont.bin > data/r6502_portfont.bin.s
|
||||
$(AS) -o data/r6502_portfont.bin.o data/r6502_portfont.bin.s
|
||||
endif
|
@ -1,162 +0,0 @@
|
||||
program SimpleBGScroll;
|
||||
|
||||
uses
|
||||
ctypes, gba;
|
||||
|
||||
{$l data\r6502_portfont.bin.o}
|
||||
|
||||
|
||||
var
|
||||
MAPADDRESS: pointer;
|
||||
r6502_portfont_bin: array [0..0] of cuint8; cvar; external;
|
||||
r6502_portfont_bin_size: array [0..0] of cuint32; cvar; external;
|
||||
r6502_portfont_bin_end: array [0..0] of cuint8; cvar; external;
|
||||
|
||||
const
|
||||
DELAY = 2; // slow things down
|
||||
TILEWIDTH = 8; // how much to scroll
|
||||
ROW = 10; // what row to place text at
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
var
|
||||
palette: array [0..6] of u16;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
const
|
||||
message = ' ' +
|
||||
'Hello, this is an example of an oldschool simple tile scroller ' +
|
||||
'not unlike how it was done in days of yore. The ''@'' symbol ' +
|
||||
'at the top of your screen is intentional, to dispel the illusion ' +
|
||||
'of this scroller, to demonstrate the simple concept behind it. ' +
|
||||
'Check out the source to learn how it works. It is very simple! ' +
|
||||
'This exercise brought to you by r6502... ' +
|
||||
'Text is about to restart... ';
|
||||
|
||||
|
||||
|
||||
procedure updatescrolltext(idx: u32);
|
||||
var
|
||||
i: integer;
|
||||
temppointer: pu16;
|
||||
begin
|
||||
temppointer := pu16(MAPADDRESS + (ROW * 32));
|
||||
|
||||
// write out a whole row of text to the map
|
||||
for i :=0 to 31 do
|
||||
begin
|
||||
// check for end of message so we can wrap around properly
|
||||
if (message[idx] = #0) then
|
||||
idx := 0;
|
||||
|
||||
// write a character - we subtract 32, because the font graphics
|
||||
// start at tile 0, but our text is in ascii (starting at 32 and up)
|
||||
// in other words, tile 0 is a space in our font, but in ascii a
|
||||
// space is 32 so we must account for that difference between the two.
|
||||
temppointer^ := Ord(message[idx]) - 32;
|
||||
inc(temppointer);
|
||||
inc(idx);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
i, scrollx, scrolldelay, textindex: integer;
|
||||
temppointer: pu16;
|
||||
|
||||
begin
|
||||
MAPADDRESS := MAP_BASE_ADR(31); // our base map address
|
||||
|
||||
palette[0] := RGB8($40,$80,$c0);
|
||||
palette[1] := RGB8($FF,$FF,$FF);
|
||||
palette[2] := RGB8($F5,$FF,$FF);
|
||||
palette[3] := RGB8($DF,$FF,$F2);
|
||||
palette[4] := RGB8($CA,$FF,$E2);
|
||||
palette[5] := RGB8($B7,$FD,$D8);
|
||||
palette[6] := RGB8($2C,$4F,$8B);
|
||||
|
||||
// Set up the interrupt handlers
|
||||
irqInit();
|
||||
// Enable Vblank Interrupt to allow VblankIntrWait
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
// Allow Interrupts
|
||||
REG_IME^ := 1;
|
||||
|
||||
// load the palette for the background, 7 colors
|
||||
temppointer := BG_COLORS;
|
||||
|
||||
for i := 0 to 6 do
|
||||
begin
|
||||
temppointer^ := palette[i];
|
||||
inc(temppointer);
|
||||
end;
|
||||
|
||||
// load the font into gba video mem (48 characters, 4bit tiles)
|
||||
|
||||
CpuFastSet(@r6502_portfont_bin, pu16(VRAM), (r6502_portfont_bin_size[0] div 4) or COPY32);
|
||||
|
||||
// clear screen map with tile 0 ('space' tile) (256x256 halfwords)
|
||||
|
||||
//MAP_BASE_ADR(31) := nil;
|
||||
CpuFastSet( MAP_BASE_ADR(31), MAP_BASE_ADR(31), FILL or COPY32 or ($800 div 4));
|
||||
|
||||
// set screen H and V scroll positions
|
||||
BG_OFFSET[0].x := 0;
|
||||
BG_OFFSET[0].y := 0;
|
||||
|
||||
// initialize our variables
|
||||
scrollx := 0;
|
||||
textindex := 0;
|
||||
scrolldelay := 0;
|
||||
|
||||
// put the '@' symbol on the top of the screen to show how
|
||||
// the screen is only scrolling 7 pixels - to reveal the
|
||||
// illusion of how the scroller works
|
||||
pu16((MAPADDRESS + 1))^ := $20; // 0x20 == '@'
|
||||
|
||||
// draw a row of text from beginning of message
|
||||
updatescrolltext(0);
|
||||
|
||||
// set the screen base to 31 (0x600F800) and char base to 0 (0x6000000)
|
||||
BGCTRL[0] := SCREEN_BASE(31);
|
||||
|
||||
// screen mode & background to display
|
||||
SetMode( MODE_0 or BG0_ON );
|
||||
|
||||
while true do
|
||||
begin
|
||||
VBlankIntrWait();
|
||||
|
||||
// check if we reached our delay
|
||||
if (scrolldelay = DELAY) then
|
||||
begin
|
||||
// yes, the delay is complete, so let's reset it
|
||||
scrolldelay := 0;
|
||||
|
||||
// check if we reached our scrollcount
|
||||
if (scrollx = (TILEWIDTH-1)) then
|
||||
begin
|
||||
// yes, we've scrolled enough, so let's reset the count
|
||||
scrollx := 0;
|
||||
|
||||
// check if we reached the end of our scrolltext
|
||||
// and if so we need to restart our index
|
||||
if (message[textindex] = #0) then
|
||||
textindex := 0
|
||||
else
|
||||
inc(textindex);
|
||||
|
||||
// finally, let's update the scrolltext with the current text index
|
||||
updatescrolltext(textindex);
|
||||
end else
|
||||
inc(scrollx);
|
||||
end else
|
||||
inc(scrolldelay);
|
||||
|
||||
// update the hardware horizontal scroll register
|
||||
BG_OFFSET[0].x := scrollx;
|
||||
end;
|
||||
end.
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
||||
#
|
||||
# Makefile.fpc for Free Pascal libgbafpc 2.x.y Examples
|
||||
#
|
||||
|
||||
[target]
|
||||
programs=console
|
||||
|
||||
[require]
|
||||
packages=libgbafpc
|
||||
|
||||
[install]
|
||||
fpcpackage=y
|
||||
|
||||
[default]
|
||||
cpu=arm
|
||||
target=gba
|
||||
fpcdir=../../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
@ -1,60 +0,0 @@
|
||||
program console;
|
||||
|
||||
uses
|
||||
gba;
|
||||
|
||||
begin
|
||||
// the vblank interrupt must be enabled for VBlankIntrWait() to work
|
||||
// since the default dispatcher handles the bios flags no vblank handler
|
||||
// is required
|
||||
irqInit();
|
||||
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
// initialise the console
|
||||
// setting NULL & 0 for the font address & size uses the default font
|
||||
// The font should be a complete 1bit 8x8 ASCII font
|
||||
consoleInit( 0, // charbase
|
||||
4, // mapbase
|
||||
0, // background number
|
||||
nil, // font
|
||||
0, // font size
|
||||
15 // 16 color palette
|
||||
);
|
||||
|
||||
// set the screen colors, color 0 is the background color
|
||||
// the foreground color is index 1 of the selected 16 color palette
|
||||
BG_COLORS[0] := RGB8(58,110,165);
|
||||
BG_COLORS[241] := RGB5(31,31,31);
|
||||
|
||||
SetMode(MODE_0 or BG0_ON);
|
||||
|
||||
// ansi escape sequence to clear screen and home cursor
|
||||
// /x1b[line;columnH
|
||||
iprintf(#27'[2J');
|
||||
|
||||
// ansi escape sequence to set print co-ordinates
|
||||
// /x1b[line;columnH
|
||||
iprintf(#27'[10;10H' + 'Hello World!');
|
||||
|
||||
// ansi escape sequence to move cursor up
|
||||
// /x1b[linesA
|
||||
iprintf(#27'[10A' + 'Line 0');
|
||||
|
||||
// ansi escape sequence to move cursor left
|
||||
// /x1b[columnsD
|
||||
iprintf(#27'[28D' + 'Column 0');
|
||||
|
||||
// ansi escape sequence to move cursor down
|
||||
// /x1b[linesB
|
||||
iprintf(#27'[19B' + 'Line 19');
|
||||
|
||||
// ansi escape sequence to move cursor right
|
||||
// /x1b[columnsC
|
||||
iprintf(#27'[5C' + 'Column 20');
|
||||
|
||||
while true do
|
||||
VBlankIntrWait();
|
||||
|
||||
end.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +0,0 @@
|
||||
#
|
||||
# Makefile.fpc for Free Pascal libgbafpc 2.x.y Examples
|
||||
#
|
||||
|
||||
[target]
|
||||
programs=template
|
||||
|
||||
[require]
|
||||
packages=libgbafpc
|
||||
|
||||
[install]
|
||||
fpcpackage=y
|
||||
|
||||
[default]
|
||||
cpu=arm
|
||||
target=gba
|
||||
fpcdir=../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
@ -1,45 +0,0 @@
|
||||
program template;
|
||||
|
||||
uses
|
||||
ctypes, gba;
|
||||
|
||||
|
||||
|
||||
var
|
||||
frame: integer = 0;
|
||||
zbuffer: array [0..239, 0..159] of u8; cvar; external; //EWRAM_BSS;
|
||||
|
||||
|
||||
procedure Vblank();
|
||||
begin
|
||||
frame := frame + 1;
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
// the vblank interrupt must be enabled for VBlankIntrWait() to work
|
||||
// since the default dispatcher handles the bios flags no vblank handler
|
||||
// is required
|
||||
irqInit();
|
||||
irqSet(IRQ_VBLANK, @Vblank);
|
||||
irqEnable(IRQ_VBLANK);
|
||||
|
||||
consoleInit(0, 4, 0, nil, 0, 15);
|
||||
|
||||
BG_COLORS[0] := RGB8(58,110,165);
|
||||
BG_COLORS[241] := RGB5(31,31,31);
|
||||
|
||||
SetMode(MODE_0 or BG0_ON);
|
||||
|
||||
// ansi escape sequence to set print co-ordinates
|
||||
// /x1b[line;columnH
|
||||
iprintf(#27'[10;10H' + 'Hello World!'#10);
|
||||
iprintf('%x', getmem(200));
|
||||
while true do
|
||||
begin
|
||||
VBlankIntrWait();
|
||||
scanKeys();
|
||||
end;
|
||||
end.
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program watch;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -20,8 +20,9 @@ target=nds
|
||||
fpcdir=../../../../../..
|
||||
|
||||
[clean]
|
||||
files=*.elf *.o *.s *.nds *.nef *.h *.bin \
|
||||
$(BUILD)/*
|
||||
files=*.elf *.o *.s *.nds *.nef *.h *.bin *.map \
|
||||
$(BUILD)/* \
|
||||
$(INC)/*
|
||||
units=*
|
||||
|
||||
[prerules]
|
||||
@ -31,7 +32,16 @@ GFX_FILES = $(foreach dir,gfx,$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
[rules]
|
||||
.NOTPARALLEL:
|
||||
clean: dir_delete fpc_clean fpc_cleanall
|
||||
all: direc fpc_all
|
||||
|
||||
#
|
||||
# Delete temp directories
|
||||
#
|
||||
dir_delete:
|
||||
@$(DELTREE) $(CURDIR)/$(BUILD)
|
||||
@$(DELTREE) $(CURDIR)/$(INC)
|
||||
|
||||
direc:
|
||||
ifneq ($(BUILD), $(CURDIR))
|
||||
$(MKDIR) $(BUILD)
|
||||
|
@ -1,6 +1,7 @@
|
||||
program AudioModes;
|
||||
{$L build/soundbank.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
uses
|
||||
ctypes, nds9, maxmod9;
|
||||
|
||||
@ -42,31 +43,22 @@ const
|
||||
MSL_NSAMPS = 65;
|
||||
MSL_BANKSIZE = 68;
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
SHOW_TEXT = #10 +
|
||||
|
||||
' Maxmod Audio Modes Example'#10#10 +
|
||||
|
||||
' Song: '#10 +
|
||||
' Mode: '#10#10 +
|
||||
|
||||
' Left/Right: Select Song'#10 +
|
||||
' Up/Down: Change Audio Mode'#10 +
|
||||
' A: Start Playback'#10 +
|
||||
' B: Stop Playback'#10#10 +
|
||||
|
||||
' Tip: Play subtonal with the'#10 +
|
||||
' extended mode or else it won''t'#10 +
|
||||
' sound right.'#10#10 +
|
||||
|
||||
' Another Tip: The interpolated'#10 +
|
||||
' mode doesn''t work in current'#10 +
|
||||
' emulators.';
|
||||
//---------------------------------------------
|
||||
|
||||
|
||||
SHOW_TEXT: pchar = #10 +
|
||||
' Maxmod Audio Modes Example'#10#10 +
|
||||
' Song: '#10 +
|
||||
' Mode: '#10#10 +
|
||||
' Left/Right: Select Song'#10 +
|
||||
' Up/Down: Change Audio Mode'#10 +
|
||||
' A: Start Playback'#10 +
|
||||
' B: Stop Playback'#10#10 +
|
||||
|
||||
' Tip: Play subtonal with the'#10 +
|
||||
' extended mode or else it won''t'#10 +
|
||||
' sound right.'#10#10 +
|
||||
|
||||
' Another Tip: The interpolated'#10 +
|
||||
' mode doesn''t work in current'#10 +
|
||||
' emulators.';
|
||||
|
||||
|
||||
var
|
||||
|
@ -59,13 +59,13 @@ begin
|
||||
|
||||
// ansi escape sequence to clear screen and home cursor
|
||||
// /x1b[line;columnH
|
||||
iprintf(#27 + '[2J');
|
||||
iprintf(#$1b'[2J');
|
||||
|
||||
// ansi escape sequence to set print co-ordinates
|
||||
// /x1b[line;columnH
|
||||
iprintf(#27 + '[0;8HMaxMod Audio demo');
|
||||
iprintf(#27 + '[3;0HHold A for ambulance sound');
|
||||
iprintf(#27 + '[4;0HPress B for boom sound');
|
||||
iprintf(#$1b'[0;8HMaxMod Audio demo');
|
||||
iprintf(#$1b'[3;0HHold A for ambulance sound');
|
||||
iprintf(#$1b'[4;0HPress B for boom sound');
|
||||
|
||||
// sound effect handle (for cancelling it later)
|
||||
amb := 0;
|
||||
|
@ -33,7 +33,7 @@ var
|
||||
//---------------------------------------------------------------------------------
|
||||
// callback function to handle song events
|
||||
//---------------------------------------------------------------------------------
|
||||
function myEventHandler(msg, param: mm_word): pmm_word;
|
||||
function myEventHandler(msg, param: mm_word): mm_callback;//pmm_word;
|
||||
begin
|
||||
case msg of
|
||||
|
||||
|
@ -37,7 +37,7 @@ var
|
||||
sprites: array[0..4] of MySprite;
|
||||
|
||||
|
||||
function myEventHandler(msg, param: mm_word): mm_word;
|
||||
function myEventHandler(msg, param: mm_word): mm_callback;
|
||||
begin
|
||||
case msg of
|
||||
MMCB_SONGMESSAGE: // process song messages
|
||||
@ -50,7 +50,7 @@ begin
|
||||
end;
|
||||
MMCB_SONGFINISHED:; // process song finish message (only triggered in songs played with MM_PLAY_ONCE)
|
||||
end;
|
||||
result := 0;
|
||||
result := nil;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program micrecord;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9, maxmod9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program eeprom;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9, sysutils;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
program main;
|
||||
program exceptionTest;
|
||||
|
||||
{$apptype arm9}
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
|
@ -1,5 +1,6 @@
|
||||
program dsMotion;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
@ -1,11 +1,7 @@
|
||||
program apSearch;
|
||||
|
||||
{$apptype arm9}
|
||||
{$define ARM9}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
|
||||
uses
|
||||
ctypes, nds9, dswifi9;
|
||||
|
||||
@ -57,7 +53,7 @@ begin
|
||||
end;
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
function keyPressed(c: cint): pointer;
|
||||
procedure keyPressed(c: cint);
|
||||
begin
|
||||
if (c > 0) then
|
||||
iprintf('%c', c);
|
||||
|
@ -1,15 +1,10 @@
|
||||
program autoconnect;
|
||||
|
||||
{$apptype arm9}
|
||||
{$define ARM9}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
|
||||
uses
|
||||
ctypes, nds9, dswifi9;
|
||||
|
||||
|
||||
var
|
||||
ip, gateway, mask, dns1, dns2: in_addr;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
program embedded_gbfs;
|
||||
{$mode objfpc}
|
||||
{$L build/data.gbfs.o}
|
||||
uses
|
||||
ctypes, nds9, gbfs;
|
||||
|
@ -1,6 +1,5 @@
|
||||
program access_dir;
|
||||
|
||||
{$apptype arm9}
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
|
@ -1,5 +1,7 @@
|
||||
program BothScreens3D;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program Box_Test;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program DisplayList;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program DisplayList2;
|
||||
{$L build/teapot.bin.o}
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -2,6 +2,8 @@ program EnvMapping;
|
||||
{$L build/teapot.bin.o}
|
||||
{$L build/cafe.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program MixedText3D;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9, math;
|
||||
|
||||
|
@ -19,6 +19,8 @@ program PalettedCube;
|
||||
{$L build/texture9_RGB32_A3_pal.bin.o}
|
||||
{$L build/texture9_RGB32_A3_tex.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -3,6 +3,8 @@ program picking;
|
||||
{$L build/cylinder.bin.o}
|
||||
{$L build/sphere.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
program SimpleQuad;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
||||
var
|
||||
rotateX: cfloat = 0.0;
|
||||
rotateY: cfloat = 0.0;
|
||||
|
@ -1,5 +1,7 @@
|
||||
program SimpleTri;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -2,8 +2,6 @@ program TexturedCube;
|
||||
|
||||
{$L build/texture.bin.o}
|
||||
|
||||
{$apptype arm9}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
|
@ -1,6 +1,6 @@
|
||||
program TextureQuad;
|
||||
{$L build/texture.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -2,6 +2,7 @@ program ToonShading;
|
||||
//NB: This would look better if the object had a bit of texturing too (eyes, nose etc)
|
||||
|
||||
{$L build/statue.bin.o}
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
@ -1,6 +1,8 @@
|
||||
program bmp_16bit_color;
|
||||
{$L build/drunkenlogo.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
program bmp_256_color;
|
||||
{$L build/drunkenlogo.o}
|
||||
|
||||
{$apptype arm9}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
|
@ -1,5 +1,7 @@
|
||||
program DoubleBuffer;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -3,6 +3,8 @@ program AllInOne;
|
||||
{$L build/TextBackgrounds.o}
|
||||
{$L build/Multilayer.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9, basic, advanced, handmade, scrolling;
|
||||
|
||||
|
@ -2,6 +2,8 @@ program BG_Rotation;
|
||||
{$L build/drunkenlogo.bin.o}
|
||||
{$L build/palette.bin.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program AnsiConsole;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program ConsoleWindows;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
program custom_font;
|
||||
{$L build/font.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
@ -19,8 +21,8 @@ var
|
||||
|
||||
|
||||
begin
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
vramSetBankC(VRAM_C_SUB_BG);
|
||||
|
||||
console := consoleInit(nil, 0, BgType_Text4bpp, BgSize_T_256x256, map_base, tile_base, false, false);
|
||||
|
||||
@ -33,7 +35,7 @@ begin
|
||||
font.convertSingleColor := false;
|
||||
|
||||
consoleSetFont(console, @font);
|
||||
|
||||
|
||||
printf('Custom Font Demo'#10);
|
||||
printf(' by Poffy'#10);
|
||||
printf('modified by WinterMute'#10);
|
||||
|
@ -1,7 +1,5 @@
|
||||
program printBothScreens;
|
||||
|
||||
{$apptype arm9}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
@ -10,7 +8,6 @@ uses
|
||||
var
|
||||
touch: touchPosition;
|
||||
topScreen, bottomScreen: PrintConsole;
|
||||
// p: PrintConsole;
|
||||
|
||||
begin
|
||||
videoSetMode(MODE_0_2D);
|
||||
@ -22,13 +19,6 @@ begin
|
||||
consoleInit(@topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true);
|
||||
consoleInit(@bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
|
||||
|
||||
|
||||
{
|
||||
topScreen := consoleInit(nil, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, true);
|
||||
p := topScreen^;
|
||||
bottomScreen := consoleInit(nil, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false);
|
||||
topScreen := @p;
|
||||
}
|
||||
consoleSelect(@topScreen);
|
||||
|
||||
iprintf(#10#10#9'Hello DS dev''rs'#10);
|
||||
|
@ -1,6 +1,8 @@
|
||||
program RotscaleText;
|
||||
{$L build/font.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
program AllocationTest;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
@ -120,7 +121,7 @@ var
|
||||
begin
|
||||
//sort our sprites on z
|
||||
//a more efficient way would be to keep a sorted list of sprites
|
||||
qsort(@sprites, SPRITE_MAX, sizeof(TMySprite), @zsort);
|
||||
qsort(@sprites, SPRITE_MAX, sizeof(TMySprite), TSort(@zsort));
|
||||
|
||||
//set oam to values required by my sprite
|
||||
for i := 0 to SPRITE_MAX - 1 do
|
||||
@ -178,7 +179,7 @@ begin
|
||||
end;
|
||||
|
||||
var
|
||||
memUsageTemp: cint;// = $FFFFFFFF;
|
||||
memUsageTemp: longint;// = $FFFFFFFF;
|
||||
|
||||
begin
|
||||
randomize;
|
||||
|
@ -42,10 +42,11 @@ program AnimateSimple;
|
||||
{$L build/man.o}
|
||||
{$L build/woman.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
||||
var
|
||||
manTiles: array [0..3071] of cuint; cvar; external;
|
||||
manPal: array [0..255] of cushort; cvar; external;
|
||||
|
@ -1,5 +1,7 @@
|
||||
program BitmapSprites;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
program FireAndSprites;
|
||||
{$L build/ball.pcx.o}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
program Simple;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
||||
var
|
||||
i: integer;
|
||||
touch: touchPosition;
|
||||
@ -39,42 +40,42 @@ begin
|
||||
touchRead(touch);
|
||||
|
||||
oamSet(oamMain, //main graphics engine context
|
||||
0, //oam index (0 to 127)
|
||||
0, //oam index (0 to 127)
|
||||
touch.px, touch.py, //x and y pixle location of the sprite
|
||||
0, //priority, lower renders last (on top)
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx, //pointer to the loaded graphics
|
||||
-1, //sprite rotation data
|
||||
-1, //sprite rotation data
|
||||
false, //double the size when rotating?
|
||||
false, //hide the sprite?
|
||||
false, false, //vflip, hflip
|
||||
false //apply mosaic
|
||||
);
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
oamSet(oamSub,
|
||||
0,
|
||||
touch.px,
|
||||
touch.py,
|
||||
0,
|
||||
0,
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfxSub,
|
||||
-1,
|
||||
false,
|
||||
false,
|
||||
false, false,
|
||||
false
|
||||
);
|
||||
|
||||
touch.px,
|
||||
touch.py,
|
||||
0,
|
||||
0,
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfxSub,
|
||||
-1,
|
||||
false,
|
||||
false,
|
||||
false, false,
|
||||
false
|
||||
);
|
||||
|
||||
swiWaitForVBlank();
|
||||
|
||||
|
||||
|
||||
oamUpdate(oamMain);
|
||||
oamUpdate(oamSub);
|
||||
end;
|
||||
|
||||
end.
|
||||
end.
|
@ -1,5 +1,7 @@
|
||||
program SpriteExtendedPalettes;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
@ -32,8 +34,8 @@ begin
|
||||
//------------------------------------------------------------------
|
||||
vramSetBankF(VRAM_F_LCD);
|
||||
|
||||
VRAM_F_EXT_PALETTE[0][1] := RGB15(31,0,0);
|
||||
VRAM_F_EXT_PALETTE[1][1] := RGB15(0,31,0);
|
||||
VRAM_F_EXT_PALETTE^[0][1] := RGB15(31,0,0);
|
||||
VRAM_F_EXT_PALETTE^[1][1] := RGB15(0,31,0);
|
||||
|
||||
// set vram to ex palette
|
||||
vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE);
|
||||
@ -46,40 +48,40 @@ begin
|
||||
touchRead(touch);
|
||||
|
||||
oamSet(oamMain, //main graphics engine context
|
||||
0, //oam index (0 to 127)
|
||||
0, //oam index (0 to 127)
|
||||
touch.px, touch.py, //x and y pixle location of the sprite
|
||||
0, //priority, lower renders last (on top)
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx1, //pointer to the loaded graphics
|
||||
-1, //sprite rotation data
|
||||
-1, //sprite rotation data
|
||||
false, //double the size when rotating?
|
||||
false, //hide the sprite?
|
||||
false, false, //vflip, hflip
|
||||
false //apply mosaic
|
||||
);
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
oamSet(oamMain,
|
||||
1,
|
||||
SCREEN_WIDTH - touch.px,
|
||||
SCREEN_HEIGHT - touch.py,
|
||||
0,
|
||||
1,
|
||||
SCREEN_WIDTH - touch.px,
|
||||
SCREEN_HEIGHT - touch.py,
|
||||
0,
|
||||
1, //use second palette
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx2,
|
||||
-1,
|
||||
false,
|
||||
false,
|
||||
false, false,
|
||||
false
|
||||
);
|
||||
|
||||
SpriteSize_16x16,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx2,
|
||||
-1,
|
||||
false,
|
||||
false,
|
||||
false, false,
|
||||
false
|
||||
);
|
||||
|
||||
swiWaitForVBlank();
|
||||
|
||||
|
||||
|
||||
oamUpdate(oamMain);
|
||||
end;
|
||||
end.
|
||||
end.
|
@ -1,5 +1,7 @@
|
||||
program SpriteRotate;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
@ -40,43 +42,43 @@ begin
|
||||
// width (20 - 16, 20 - 16, )
|
||||
//-------------------------------------------------------------------------
|
||||
oamRotateScale(oamMain, 0, angle, intToFixed(1, 8), intToFixed(1, 8));
|
||||
|
||||
|
||||
oamSet(oamMain, //main graphics engine context
|
||||
0, //oam index (0 to 127)
|
||||
0, //oam index (0 to 127)
|
||||
20 - 16, 20 - 16, //x and y pixle location of the sprite
|
||||
0, //priority, lower renders last (on top)
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_32x32,
|
||||
SpriteColorFormat_256Color,
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_32x32,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx, //pointer to the loaded graphics
|
||||
0, //sprite rotation/scale matrix index
|
||||
0, //sprite rotation/scale matrix index
|
||||
true, //double the size when rotating?
|
||||
false, //hide the sprite?
|
||||
false, false, //vflip, hflip
|
||||
false //apply mosaic
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Because the sprite below has size double set to false it can never be larger than
|
||||
// 32x32 causing it to clip as it rotates.
|
||||
// 32x32 causing it to clip as it rotates.
|
||||
//-------------------------------------------------------------------------
|
||||
oamSet(oamMain, //main graphics engine context
|
||||
1, //oam index (0 to 127)
|
||||
1, //oam index (0 to 127)
|
||||
204, 20, //x and y pixle location of the sprite
|
||||
0, //priority, lower renders last (on top)
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_32x32,
|
||||
SpriteColorFormat_256Color,
|
||||
0, //this is the palette index if multiple palettes or the alpha value if bmp sprite
|
||||
SpriteSize_32x32,
|
||||
SpriteColorFormat_256Color,
|
||||
gfx, //pointer to the loaded graphics
|
||||
0, //sprite rotation/scale matrix index
|
||||
0, //sprite rotation/scale matrix index
|
||||
false, //double the size when rotating?
|
||||
false, //hide the sprite?
|
||||
false, false, //vflip, hflip
|
||||
false //apply mosaic
|
||||
);
|
||||
);
|
||||
swiWaitForVBlank();
|
||||
|
||||
|
||||
|
||||
oamUpdate(oamMain);
|
||||
end;
|
||||
end.
|
||||
end.
|
@ -1,5 +1,7 @@
|
||||
program hello_world;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
program keyboardAsync;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
program keyboardStdin;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
uses
|
||||
ctypes, nds9;
|
||||
|
||||
function OnKeyPressed(key: cint): pointer;
|
||||
procedure OnKeyPressed(key: cint);
|
||||
begin
|
||||
if (key > 0) then
|
||||
iprintf('%c', key);
|
||||
|
@ -21,14 +21,14 @@ uses
|
||||
{$linklib sysbase}
|
||||
|
||||
{$define NDS_INTERFACE}
|
||||
{$include fathelper.inc}
|
||||
{ $include fathelper.inc}
|
||||
{$include ../nds/disc_io.inc}
|
||||
{$include fat.inc}
|
||||
{$undef NDS_INTERFACE}
|
||||
|
||||
implementation
|
||||
{$define NDS_IMPLEMENTATION}
|
||||
{$include fathelper.inc}
|
||||
{ $include fathelper.inc}
|
||||
{$include ../nds/disc_io.inc}
|
||||
{$include fat.inc}
|
||||
{$undef NDS_IMPLEMENTATION}
|
||||
|
@ -21,14 +21,14 @@ uses
|
||||
{$linklib sysbase}
|
||||
|
||||
{$define NDS_INTERFACE}
|
||||
{$include fathelper.inc}
|
||||
{ $include fathelper.inc}
|
||||
{$include ../nds/disc_io.inc}
|
||||
{$include filesystem.inc}
|
||||
{$undef NDS_INTERFACE}
|
||||
|
||||
implementation
|
||||
{$define NDS_IMPLEMENTATION}
|
||||
{$include fathelper.inc}
|
||||
{ $include fathelper.inc}
|
||||
{$include ../nds/disc_io.inc}
|
||||
{$include filesystem.inc}
|
||||
{$undef NDS_IMPLEMENTATION}
|
||||
|
@ -59,7 +59,7 @@ procedure mmSetModuleTempo(tempo: mm_word); cdecl; external;
|
||||
procedure mmSetModulePitch(pitch: mm_word); cdecl; external;
|
||||
procedure mmPlayModule(address, mode, layer: mm_word); cdecl; external;
|
||||
function mmEffect(sample_ID: mm_word): mm_sfxhand; cdecl; external;
|
||||
function mmEffectEx(sound: pmm_sound_effect): mm_sfxhand; cdecl; external;
|
||||
function mmEffectEx(var sound: mm_sound_effect): mm_sfxhand; cdecl; external;
|
||||
procedure mmEffectVolume(handle: mm_sfxhand; volume: mm_word); cdecl; external;
|
||||
procedure mmEffectPanning(handle: mm_sfxhand; panning: mm_byte); cdecl; external;
|
||||
procedure mmEffectRate(handle: mm_sfxhand; rate: mm_word); cdecl; external;
|
||||
|
@ -104,4 +104,5 @@ procedure BCDToInteger(var data: cuint8; length: cuint32); cdecl; external;
|
||||
procedure integerToBCD(var data: cuint8; length: cuint32); cdecl; external;
|
||||
|
||||
procedure initClockIRQ(); cdecl; external;
|
||||
procedure resyncClock(); cdecl; external;
|
||||
{$endif NDS_INTERFACE}
|
||||
|
@ -515,15 +515,15 @@ end;
|
||||
procedure bgSetMosaic(dx, dy: cuint); inline;
|
||||
begin
|
||||
sassert( (dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
|
||||
MOSAIC_CR^ := MOSAIC_CR^ and not $FF;
|
||||
MOSAIC_CR^ := MOSAIC_CR^ or (dx or (dy shl 4));
|
||||
mosaicShadow := (mosaicShadow and $ff00) or (dx or (dy shl 4));
|
||||
REG_MOSAIC^ := mosaicShadow;
|
||||
end;
|
||||
|
||||
procedure bgSetMosaicSub(dx, dy: cuint); inline;
|
||||
begin
|
||||
sassert( (dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
|
||||
SUB_MOSAIC_CR^ := SUB_MOSAIC_CR^ and not $FF;
|
||||
SUB_MOSAIC_CR^ := SUB_MOSAIC_CR^ or (dx or (dy shl 4));
|
||||
mosaicShadowSub := (mosaicShadowSub and $ff00) or (dx or (dy shl 4));
|
||||
REG_MOSAIC_SUB^ := mosaicShadowSub;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -42,8 +42,8 @@
|
||||
{$ifdef NDS_INTERFACE}
|
||||
|
||||
type
|
||||
KeyChangeCallback = function(key: cint): pointer;
|
||||
// KeyChangeCallback = procedure(key: cint) of object;
|
||||
// KeyChangeCallback = function(key: cint): pointer;
|
||||
KeyChangeCallback = procedure(key: cint);
|
||||
PKeyChangeCallback = ^KeyChangeCallback;
|
||||
|
||||
KeyboardState = integer;
|
||||
@ -99,6 +99,6 @@ procedure keyboardShow(); cdecl; external;
|
||||
procedure keyboardHide(); cdecl; external;
|
||||
function keyboardGetKey(x, y: cint): cint; cdecl; external;
|
||||
procedure keyboardGetString(buffer: pchar; maxLen: cint); cdecl; external;
|
||||
function keboardGetChar(): cint; cdecl; external;
|
||||
function keyboardGetChar(): cint; cdecl; external;
|
||||
function keyboardUpdate(): cint; cdecl; external;
|
||||
{$endif NDS_INTERFACE}
|
||||
|
@ -80,6 +80,8 @@ function soundPlayNoise(freq: cuint16; volume, pan: cuint8): cint; cdecl; extern
|
||||
|
||||
procedure soundPause(soundId: cint); cdecl; external;
|
||||
|
||||
procedure soundSetWaveDuty(soundId: cint; cycle: DutyCycle); cdecl; external;
|
||||
|
||||
procedure soundKill(soundId: cint); cdecl; external;
|
||||
|
||||
procedure soundResume(soundId: cint); cdecl; external;
|
||||
|
@ -299,6 +299,7 @@ function oamAllocateGfx(var oam: OamState; size: SpriteSize; colorFormat: Sprite
|
||||
procedure oamFreeGfx(var oam: OamState; const gfxOffset: pointer); cdecl; external;
|
||||
|
||||
procedure oamSetMosaic(dx, dy: cuint); inline;
|
||||
procedure oamSetMosaicSub(dx, dy: cuint); inline;
|
||||
|
||||
procedure oamSet( var oam: OamState;
|
||||
id, x, y, priority, palette_alpha: cint;
|
||||
@ -310,6 +311,8 @@ procedure oamSet( var oam: OamState;
|
||||
procedure oamClear(var oam: OamState; start, count: cint); cdecl; external;
|
||||
procedure oamUpdate(var oam: OamState); cdecl; external;
|
||||
procedure oamRotateScale(var oam: OamState; rotId, angle, sx, sy: cint); cdecl; external;
|
||||
procedure oamAffineTransformation(var oam: OamState; rotId, hdx, hdy, vdx, vdy: cint); inline;
|
||||
|
||||
function oamCountFragments(var oam: OamState): cint; cdecl; external;
|
||||
procedure oamAllocReset(var oam: OamState); cdecl; external;
|
||||
function oamGfxPtrToOffset(const offset: pointer): cuint; cdecl; external;
|
||||
@ -364,8 +367,25 @@ end;
|
||||
procedure oamSetMosaic(dx, dy: cuint); inline;
|
||||
begin
|
||||
sassert((dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
|
||||
MOSAIC_CR^ := MOSAIC_CR^ and not ($FF00);
|
||||
MOSAIC_CR^ := MOSAIC_CR^ or ((dx shl 8) or (dy shl 12));
|
||||
mosaicShadow := ( mosaicShadow and $00ff) or (dx shl 8) or (dy shl 12);
|
||||
REG_MOSAIC^ := mosaicShadow;
|
||||
end;
|
||||
|
||||
procedure oamSetMosaicSub(dx, dy: cuint); inline;
|
||||
begin
|
||||
sassert((dx < 16) and (dy < 16), 'Mosaic range is 0 to 15');
|
||||
mosaicShadowSub := (mosaicShadowSub and $00ff) or (dx shl 8) or (dy shl 12);
|
||||
REG_MOSAIC_SUB^ := mosaicShadowSub;
|
||||
end;
|
||||
|
||||
procedure oamAffineTransformation(var oam: OamState; rotId, hdx, hdy, vdx, vdy: cint); inline;
|
||||
begin
|
||||
sassert((rotId >= 0) and (rotId < 32), 'oamAffineTransformation() rotId is out of bounds, must be 0-31');
|
||||
oam.oamRotationMemory[rotId].hdx := hdx shr 12;
|
||||
oam.oamRotationMemory[rotId].hdy := hdy shr 12;
|
||||
oam.oamRotationMemory[rotId].vdx := vdx shr 12;
|
||||
oam.oamRotationMemory[rotId].vdy := vdy shr 12;
|
||||
end;
|
||||
|
||||
|
||||
{$endif NDS_IMPLEMENTATION}
|
||||
|
@ -43,6 +43,10 @@
|
||||
{$endif ARM9}
|
||||
|
||||
{$ifdef NDS_INTERFACE}
|
||||
var
|
||||
mosaicShadow: cuint16; cvar; external;
|
||||
mosaicShadowSub: cuint16; cvar; external;
|
||||
|
||||
const
|
||||
BG_PALETTE : pcuint16 = pointer($05000000);
|
||||
BG_PALETTE_SUB : pcuint16 = pointer($05000400);
|
||||
@ -244,10 +248,10 @@ type
|
||||
P_ext_palette = ^_ext_palette;
|
||||
|
||||
var
|
||||
VRAM_E_EXT_PALETTE : P_palette absolute VRAM_E;
|
||||
VRAM_F_EXT_PALETTE : P_palette absolute VRAM_F;
|
||||
VRAM_G_EXT_PALETTE : P_palette absolute VRAM_G;
|
||||
VRAM_H_EXT_PALETTE : P_palette absolute VRAM_H;
|
||||
VRAM_E_EXT_PALETTE : P_ext_palette absolute VRAM_E;
|
||||
VRAM_F_EXT_PALETTE : P_ext_palette absolute VRAM_F;
|
||||
VRAM_G_EXT_PALETTE : P_ext_palette absolute VRAM_G;
|
||||
VRAM_H_EXT_PALETTE : P_ext_palette absolute VRAM_H;
|
||||
|
||||
function vramSetMainBanks(a: VRAM_A_TYPE; b: VRAM_B_TYPE; c: VRAM_C_TYPE; d: VRAM_D_TYPE): cuint32; cdecl; external;
|
||||
procedure vramRestoreMainBanks(vramTemp: cuint32); cdecl; external;
|
||||
@ -375,8 +379,8 @@ const
|
||||
SUB_WIN_IN : pcuint16 = pointer($04001048);
|
||||
SUB_WIN_OUT : pcuint16 = pointer($0400104A);
|
||||
|
||||
MOSAIC_CR : pcuint16 = pointer($0400004C);
|
||||
SUB_MOSAIC_CR : pcuint16 = pointer($0400104C);
|
||||
REG_MOSAIC : pcuint16 = pointer($0400004C);
|
||||
REG_MOSAIC_SUB : pcuint16 = pointer($0400104C);
|
||||
|
||||
REG_BLDCNT : pcuint16 = pointer($04000050);
|
||||
REG_BLDY : pcuint16 = pointer($04000054);
|
||||
|
@ -75,7 +75,7 @@ const
|
||||
|
||||
function inttof32(n: cint): cint32; inline;
|
||||
function f32toint(n: cint32): cint; inline;
|
||||
function floattof32(n: cfloat): cint32; inline;
|
||||
function floattof32(n: cfloat): cint32; inline; //inlining it makes impossible to pass it to another function :/
|
||||
function f32tofloat(n: cint32): cfloat; inline;
|
||||
|
||||
type
|
||||
@ -89,7 +89,7 @@ function TEXTURE_PACK(u, v: cint): cint; inline;
|
||||
//function TEXTURE_PACK(u, v: cshort): cuint; inline;
|
||||
|
||||
type
|
||||
v16 = cuint16; //cshort? // vertex 4.12 fixed format
|
||||
v16 = cshort;//cuint16? // vertex 4.12 fixed format
|
||||
|
||||
function inttov16(n: cint): cint{v16}; inline;
|
||||
function f32tov16(n: cint32): v16; inline;
|
||||
|
@ -69,10 +69,6 @@ procedure swiSoftReset(); cdecl; external;
|
||||
|
||||
procedure swiDelay(duration: cuint32); cdecl; external;
|
||||
|
||||
procedure swiIntrWait(waitForSet: cint; flags: cuint32); cdecl; external;
|
||||
|
||||
procedure swiWaitForVBlank(); cdecl; external;
|
||||
|
||||
function swiDivide(numerator, divisor: cint): cint; cdecl; external;
|
||||
function swiRemainder(numerator, divisor: cint): cint; cdecl; external;
|
||||
procedure swiDivMod(numerator, divisor: cint; var result, remainder: cint); cdecl; external;
|
||||
|
@ -86,11 +86,15 @@ var
|
||||
begin
|
||||
if (index >= v^.cur_size) then
|
||||
begin
|
||||
v^.data := ReAllocMem(v^.data, sizeof(pointer) * v^.cur_size * 2);
|
||||
FillChar(pointer(integer(v^.data^^) + v^.cur_size)^, sizeof(pointer) * v^.cur_size, 0);
|
||||
v^.cur_size := v^.cur_size * 2;
|
||||
v^.data := ReAllocMem(v^.data, sizeof(pointer) * v^.cur_size);
|
||||
end;
|
||||
{
|
||||
i := integer(v^.data);
|
||||
i := i + index;
|
||||
pointer(i) := item;
|
||||
}
|
||||
v^.data[index] := item;
|
||||
end;
|
||||
{$endif NDS_IMPLEMENTATION}
|
||||
|
@ -47,11 +47,11 @@ const
|
||||
FIFO_PM : FifoChannels = 0;
|
||||
FIFO_SOUND : FifoChannels = 1;
|
||||
FIFO_SYSTEM : FifoChannels = 2;
|
||||
FIFO_RSDV_01: FifoChannels = 3;
|
||||
FIFO_RSVD_02: FifoChannels = 4;
|
||||
FIFO_RSVD_03: FifoChannels = 5;
|
||||
FIFO_DSWIFI : FifoChannels = 6;
|
||||
FIFO_MAXMOD : FifoChannels = 7;
|
||||
FIFO_MAXMOD : FifoChannels = 3;
|
||||
FIFO_DSWIFI : FifoChannels = 4;
|
||||
FIFO_RSVD_01: FifoChannels = 5;
|
||||
FIFO_RSVD_02: FifoChannels = 6;
|
||||
FIFO_RSVD_03: FifoChannels = 7;
|
||||
FIFO_USER_01: FifoChannels = 8;
|
||||
FIFO_USER_02: FifoChannels = 9;
|
||||
FIFO_USER_03: FifoChannels = 10;
|
||||
@ -65,16 +65,17 @@ const
|
||||
type
|
||||
FifoSoundCommand = integer;
|
||||
const
|
||||
SOUND_SET_PAN : FifoSoundCommand = (0 shl 20);
|
||||
SOUND_SET_VOLUME : FifoSoundCommand = (1 shl 20);
|
||||
SOUND_SET_FREQ : FifoSoundCommand = (2 shl 20);
|
||||
SOUND_MASTER_ENABLE : FifoSoundCommand = (3 shl 20);
|
||||
SOUND_MASTER_DISABLE : FifoSoundCommand = (4 shl 20);
|
||||
SOUND_PAUSE : FifoSoundCommand = (5 shl 20);
|
||||
SOUND_RESUME : FifoSoundCommand = (6 shl 20);
|
||||
SOUND_KILL : FifoSoundCommand = (7 shl 20);
|
||||
SOUND_SET_MASTER_VOL : FifoSoundCommand = (8 shl 20);
|
||||
MIC_STOP : FifoSoundCommand = (9 shl 20);
|
||||
SOUND_SET_PAN : FifoSoundCommand = ( 0 shl 20);
|
||||
SOUND_SET_VOLUME : FifoSoundCommand = ( 1 shl 20);
|
||||
SOUND_SET_FREQ : FifoSoundCommand = ( 2 shl 20);
|
||||
SOUND_SET_WAVEDUTY : FifoSoundCommand = ( 3 shl 20);
|
||||
SOUND_MASTER_ENABLE : FifoSoundCommand = ( 4 shl 20);
|
||||
SOUND_MASTER_DISABLE : FifoSoundCommand = ( 5 shl 20);
|
||||
SOUND_PAUSE : FifoSoundCommand = ( 6 shl 20);
|
||||
SOUND_RESUME : FifoSoundCommand = ( 7 shl 20);
|
||||
SOUND_KILL : FifoSoundCommand = ( 8 shl 20);
|
||||
SET_MASTER_VOL : FifoSoundCommand = ( 9 shl 20);
|
||||
MIC_STOP : FifoSoundCommand = (10 shl 20);
|
||||
|
||||
type
|
||||
FifoSystemCommands = integer;
|
||||
@ -99,6 +100,7 @@ const
|
||||
WIFI_ENABLE : FifoWifiCommands = 0;
|
||||
WIFI_DISABLE : FifoWifiCommands = 1;
|
||||
WIFI_SYNC : FifoWifiCommands = 2;
|
||||
WIFI_STARTUP : FifoWifiCommands = 3;
|
||||
|
||||
type
|
||||
PM_LedBlinkMode = integer;
|
||||
@ -107,18 +109,8 @@ const
|
||||
PM_LED_SLEEP: PM_LedBlinkMode = (1 shl 4);
|
||||
PM_LED_BLINK: PM_LedBlinkMode = (3 shl 4);
|
||||
|
||||
const
|
||||
FIFO_CHANNEL_BITS = 4;
|
||||
FIFO_MAX_DATA_BYTES = 128;
|
||||
|
||||
{$ifdef ARM9}
|
||||
FIFO_BUFFER_ENTRIES = 512;
|
||||
{$else ARM9} // ARM7
|
||||
FIFO_BUFFER_ENTRIES = 256;
|
||||
{$endif ARM9}
|
||||
|
||||
var
|
||||
fifo_buffer: array [0..FIFO_BUFFER_ENTRIES*2-1] of cuint32; cvar; external;
|
||||
//var
|
||||
// fifo_buffer: array [0..FIFO_BUFFER_ENTRIES*2-1] of cuint32; cvar; external;
|
||||
|
||||
|
||||
{$ifdef FIFO_RIGOROUS_ERROR_CHECKING}
|
||||
@ -140,237 +132,23 @@ function fifoSetAddressHandler(channel: integer; newhandler: FifoAddressHandlerF
|
||||
function fifoSetValue32Handler(channel: integer; newhandler: FifoValue32HandlerFunc; userdata: pointer): cbool; cdecl; external;
|
||||
function fifoSetDatamsgHandler(channel: integer; newhandler: FifoDatamsgHandlerFunc; userdata: pointer): cbool; cdecl; external;
|
||||
|
||||
procedure fifoForceAddressHandler(channel: integer; newhandler: FifoAddressHandlerFunc; userdata: pointer); cdecl; external;
|
||||
procedure fifoForceValue32Handler(channel: integer; newhandler: FifoValue32HandlerFunc; userdata: pointer); cdecl; external;
|
||||
procedure fifoForceDatamsgHandler(channel: integer; newhandler: FifoDatamsgHandlerFunc; userdata: pointer); cdecl; external;
|
||||
|
||||
function fifoCheckAddress(channel: integer): cbool; cdecl; external;
|
||||
function fifoCheckValue32(channel: integer): cbool; cdecl; external;
|
||||
function fifoCheckDatamsg(channel: integer): cbool; cdecl; external;
|
||||
|
||||
function fifoCheckDatamsgLength(channel: integer): cint; cdecl; external;
|
||||
|
||||
function fifoCountDatamsg(channel: integer): cint; cdecl; external;
|
||||
|
||||
function fifoGetAddress(channel: integer): pointer; cdecl; external;
|
||||
|
||||
function fifoGetValue32(channel: integer): cuint32; cdecl; external;
|
||||
|
||||
|
||||
function fifoGetDatamsg(channel, buffersize: cint; destbuffer: pcuint8): cint; cdecl; external;
|
||||
|
||||
function fifoGetBufferUsage(): cint; cdecl; external;
|
||||
|
||||
function fifoGetLostWordCount(): cint; cdecl; external;
|
||||
|
||||
|
||||
|
||||
procedure fifoInternalSendInterrupt(); cdecl; external;
|
||||
procedure fifoInternalRecvInterrupt(); cdecl; external;
|
||||
procedure fifoInternalProtect(); cdecl; external;
|
||||
procedure fifoInternalUnprotect(); cdecl; external;
|
||||
function fifoInternalSend(firstword: cuint32; extrawordcount: cint; wordlist: pcuint32): cbool; cdecl; external;
|
||||
procedure fifoInternalBeginSend(); cdecl; external;
|
||||
function fifoInternalRecvPeek(): cuint32; cdecl; external;
|
||||
function fifoInternalRecvPopFirst(): cuint32; cdecl; external;
|
||||
function fifoInternalRecvWordCount(): cint; cdecl; external;
|
||||
function fifoInternalRecvPushBack(word: cuint32): cbool; cdecl; external;
|
||||
function fifoInternalSendEmpty(): cbool; cdecl; external;
|
||||
function fifoInternalSendDeque(): cuint32; cdecl; external;
|
||||
function fifoInternalSendEnqueue(word: cuint32): cbool; cdecl; external;
|
||||
function fifoInternalAllocFreeBlock(): cint; cdecl; external;
|
||||
procedure fifoInternalFreeBlock(blockid: cint); cdecl; external;
|
||||
function fifoInternalFreeCheck(num_words: cint): cbool; cdecl; external;
|
||||
|
||||
|
||||
|
||||
|
||||
// And some aspects of the configuration can't be changed
|
||||
// please don't edit below this line.
|
||||
|
||||
const
|
||||
FIFO_ADDRESSDATA_SHIFT = 0;
|
||||
FIFO_MINADDRESSDATABITS = 22;
|
||||
FIFO_ADDRESSDATA_MASK = $003FFFFF;
|
||||
FIFO_ADDRESSBASE = $02000000;
|
||||
FIFO_ADDRESSCOMPATIBLE = $FFC00000;
|
||||
|
||||
FIFO_NUM_CHANNELS = (1 shl FIFO_CHANNEL_BITS);
|
||||
FIFO_CHANNEL_SHIFT = (32 - FIFO_CHANNEL_BITS);
|
||||
FIFO_CHANNEL_MASK = ((1 shl FIFO_CHANNEL_BITS) - 1);
|
||||
|
||||
FIFO_ADDRESSBIT_SHIFT = (FIFO_CHANNEL_SHIFT - 1);
|
||||
FIFO_ADDRESSBIT = (1 shl FIFO_ADDRESSBIT_SHIFT);
|
||||
|
||||
FIFO_IMMEDIATEBIT_SHIFT = (FIFO_CHANNEL_SHIFT - 2);
|
||||
FIFO_IMMEDIATEBIT = (1 shl FIFO_IMMEDIATEBIT_SHIFT);
|
||||
|
||||
FIFO_EXTRABIT_SHIFT = (FIFO_CHANNEL_SHIFT - 3);
|
||||
FIFO_EXTRABIT = (1 shl FIFO_EXTRABIT_SHIFT);
|
||||
|
||||
|
||||
FIFO_VALUE32_MASK = (FIFO_EXTRABIT - 1);
|
||||
|
||||
|
||||
FIFO_BUFFER_TERMINATE = $FFFF;
|
||||
FIFO_BUFFER_NEXTMASK = $FFFF;
|
||||
|
||||
|
||||
{ $IF (FIFO_MINADDRESSDATABITS + FIFO_CHANNEL_BITS + 1) > 32}
|
||||
{ $ERROR Too many channel bits - control word isn't big enough for address packet}
|
||||
{ $ENDIF}
|
||||
|
||||
|
||||
|
||||
|
||||
function FIFO_PACK_ADDRESS(channel, address: cint): cint; inline;
|
||||
function FIFO_VALUE32_NEEDEXTRA(value32: cint32): boolean; inline;
|
||||
function FIFO_PACK_VALUE32(channel, value32: cint): cint; inline;
|
||||
function FIFO_PACK_VALUE32_EXTRA(channel: cint): cint; inline;
|
||||
function FIFO_IS_ADDRESS_COMPATIBLE(address: cint): boolean; inline;
|
||||
function FIFO_PACK_DATAMSG_HEADER(channel, numwords: cint): cint; inline;
|
||||
function FIFO_IS_ADDRESS(dataword: cint): boolean; inline;
|
||||
function FIFO_IS_VALUE32(dataword: cint): boolean; inline;
|
||||
function FIFO_IS_DATA(dataword: cint): boolean; inline;
|
||||
function FIFO_UNPACK_CHANNEL(dataword: cint): cint; inline;
|
||||
function FIFO_UNPACK_ADDRESS(dataword: cint): pointer; inline;
|
||||
function FIFO_UNPACK_VALUE32_NEEDEXTRA(dataword: cint): boolean; inline;
|
||||
function FIFO_UNPACK_VALUE32_NOEXTRA(dataword: cint): cint; inline;
|
||||
function FIFO_UNPACK_DATALENGTH(dataword: cint): cint; inline;
|
||||
|
||||
const
|
||||
FIFO_BUFFERCONTROL_UNUSED = 0;
|
||||
FIFO_BUFFERCONTROL_SENDWORD = 1;
|
||||
FIFO_BUFFERCONTROL_RECVWORD = 2;
|
||||
FIFO_BUFFERCONTROL_ADDRESS = 3;
|
||||
FIFO_BUFFERCONTROL_VALUE32 = 4;
|
||||
FIFO_BUFFERCONTROL_DATASTART = 5;
|
||||
FIFO_BUFFERCONTROL_DATA = 6;
|
||||
|
||||
function FIFO_BUFFER_DATA(index: cint): cint; inline;
|
||||
function FIFO_BUFFER_DATA_BYTE(index, byteindex: cint): pcuint8; inline;
|
||||
function FIFO_BUFFER_GETNEXT(index: cint): cint; inline;
|
||||
function FIFO_BUFFER_GETCONTROL(index: cint): cint; inline;
|
||||
function FIFO_BUFFER_GETEXTRA(index: cint): cint; inline;
|
||||
procedure FIFO_BUFFER_SETCONTROL(index,next,control,extra: cint); inline;
|
||||
procedure FIFO_BUFFER_SETNEXT(index, next: cint); inline;
|
||||
|
||||
|
||||
{$endif NDS_INTERFACE}
|
||||
|
||||
|
||||
|
||||
{$ifdef NDS_IMPLEMENTATION}
|
||||
|
||||
function FIFO_PACK_ADDRESS(channel, address: cint): cint; inline;
|
||||
begin
|
||||
result := ((channel) shl FIFO_CHANNEL_SHIFT) or
|
||||
FIFO_ADDRESSBIT or
|
||||
((address shr FIFO_ADDRESSDATA_SHIFT) and FIFO_ADDRESSDATA_MASK);
|
||||
end;
|
||||
|
||||
function FIFO_VALUE32_NEEDEXTRA(value32: cint32): boolean; inline;
|
||||
begin
|
||||
result := (value32 and (not FIFO_VALUE32_MASK)) <> 0;
|
||||
end;
|
||||
|
||||
function FIFO_PACK_VALUE32(channel, value32: cint): cint; inline;
|
||||
begin
|
||||
result := (channel shl FIFO_CHANNEL_SHIFT) or
|
||||
FIFO_IMMEDIATEBIT or
|
||||
(value32 and FIFO_VALUE32_MASK);
|
||||
end;
|
||||
|
||||
function FIFO_PACK_VALUE32_EXTRA(channel: cint): cint; inline;
|
||||
begin
|
||||
result := (channel shl FIFO_CHANNEL_SHIFT) or FIFO_IMMEDIATEBIT or FIFO_EXTRABIT;
|
||||
end;
|
||||
|
||||
function FIFO_IS_ADDRESS_COMPATIBLE(address: cint): boolean; inline;
|
||||
begin
|
||||
result := (address and FIFO_ADDRESSCOMPATIBLE) = FIFO_ADDRESSBASE;
|
||||
end;
|
||||
|
||||
function FIFO_PACK_DATAMSG_HEADER(channel, numwords: cint): cint; inline;
|
||||
begin
|
||||
result := (channel shl FIFO_CHANNEL_SHIFT) or (numwords and FIFO_VALUE32_MASK);
|
||||
end;
|
||||
|
||||
function FIFO_IS_ADDRESS(dataword: cint): boolean; inline;
|
||||
begin
|
||||
result := (dataword and FIFO_ADDRESSBIT) <> 0;
|
||||
end;
|
||||
|
||||
function FIFO_IS_VALUE32(dataword: cint): boolean; inline;
|
||||
begin
|
||||
result := ((dataword and FIFO_ADDRESSBIT) = 0) and ((dataword and FIFO_IMMEDIATEBIT) <> 0);
|
||||
end;
|
||||
|
||||
function FIFO_IS_DATA(dataword: cint): boolean; inline;
|
||||
begin
|
||||
result := (dataword and (FIFO_ADDRESSBIT or FIFO_IMMEDIATEBIT)) = 0;
|
||||
end;
|
||||
|
||||
function FIFO_UNPACK_CHANNEL(dataword: cint): cint; inline;
|
||||
begin
|
||||
result := (dataword shr FIFO_CHANNEL_SHIFT) and FIFO_CHANNEL_MASK;
|
||||
end;
|
||||
|
||||
function FIFO_UNPACK_ADDRESS(dataword: cint): pointer; inline;
|
||||
begin
|
||||
result := pointer(((dataword and FIFO_ADDRESSDATA_MASK) shl FIFO_ADDRESSDATA_SHIFT) or FIFO_ADDRESSBASE);
|
||||
end;
|
||||
|
||||
function FIFO_UNPACK_VALUE32_NEEDEXTRA(dataword: cint): boolean; inline;
|
||||
begin
|
||||
result := (dataword and FIFO_EXTRABIT) <> 0;
|
||||
end;
|
||||
|
||||
function FIFO_UNPACK_VALUE32_NOEXTRA(dataword: cint): cint; inline;
|
||||
begin
|
||||
result := (dataword and FIFO_VALUE32_MASK);
|
||||
end;
|
||||
|
||||
function FIFO_UNPACK_DATALENGTH(dataword: cint): cint; inline;
|
||||
begin
|
||||
result := (dataword and FIFO_VALUE32_MASK);
|
||||
end;
|
||||
|
||||
function FIFO_BUFFER_DATA(index: cint): cint; inline;
|
||||
begin
|
||||
result := fifo_buffer[(index)*2+1];
|
||||
end;
|
||||
|
||||
function FIFO_BUFFER_DATA_BYTE(index, byteindex: cint): pcuint8; inline;
|
||||
begin
|
||||
// ((u8*)(&fifo_buffer[(index)*2+1]))[(byteindex)]
|
||||
///////// result := pcuint8(pointer(fifo_buffer[index*2+1]))[byteindex];
|
||||
end;
|
||||
|
||||
|
||||
function FIFO_BUFFER_GETNEXT(index: cint): cint; inline;
|
||||
begin
|
||||
result := (fifo_buffer[(index)*2] and FIFO_BUFFER_NEXTMASK);
|
||||
end;
|
||||
|
||||
function FIFO_BUFFER_GETCONTROL(index: cint): cint; inline;
|
||||
begin
|
||||
result := (fifo_buffer[(index)*2] shr 28);
|
||||
end;
|
||||
|
||||
function FIFO_BUFFER_GETEXTRA(index: cint): cint; inline;
|
||||
begin
|
||||
result := ((fifo_buffer[(index)*2] shr 16) and $FFF);
|
||||
end;
|
||||
|
||||
procedure FIFO_BUFFER_SETCONTROL(index,next,control,extra: cint); inline;
|
||||
begin
|
||||
fifo_buffer[(index)*2] := (next and FIFO_BUFFER_NEXTMASK) or (control shl 28) or ((extra and $FFF) shl 16);
|
||||
end;
|
||||
|
||||
procedure FIFO_BUFFER_SETNEXT(index, next: cint); inline;
|
||||
begin
|
||||
fifo_buffer[(index)*2] := (next and FIFO_BUFFER_NEXTMASK) or (fifo_buffer[(index)*2] and (not FIFO_BUFFER_NEXTMASK));
|
||||
end;
|
||||
|
||||
{$endif NDS_IMPLEMENTATION}
|
||||
|
@ -43,62 +43,52 @@ type
|
||||
{$PACKRECORDS 4}
|
||||
FifoMessage = record
|
||||
_type: cuint16;
|
||||
empty: array[0..31] of cuint8;
|
||||
case integer of
|
||||
0: (
|
||||
SundPlay: record
|
||||
_type: cuint16;
|
||||
data: pointer;
|
||||
loopPoint: cuint16;
|
||||
dataSize: cuint16;
|
||||
freq: cuint16;
|
||||
volume: cuint8;
|
||||
pan: cuint8;
|
||||
loop: cbool;
|
||||
format: cuint8;
|
||||
end;
|
||||
);
|
||||
1: (
|
||||
SoundPsg: record
|
||||
freq: cuint16;
|
||||
dutyCycle: cuint8;
|
||||
volume: cuint8;
|
||||
pan: cuint8;
|
||||
end;
|
||||
);
|
||||
2: (
|
||||
MicRecord: record
|
||||
buffer: pointer;
|
||||
bufferLength: cuint32;
|
||||
freq: cuint16;
|
||||
format: cuint8;
|
||||
end;
|
||||
);
|
||||
3: (
|
||||
MicBufferFull: record
|
||||
buffer: pointer;
|
||||
length: cuint32;
|
||||
end;
|
||||
);
|
||||
4: (
|
||||
SystemInput: record
|
||||
touch: touchPosition;
|
||||
keys: cuint16;
|
||||
end;
|
||||
);
|
||||
end;
|
||||
TFifoMessage = FifoMessage;
|
||||
PFifoMessage = ^FifoMessage;
|
||||
|
||||
SoundPlayMsg = record
|
||||
_type: cuint16;
|
||||
data: pointer;
|
||||
loopPoint: cuint16;
|
||||
dataSize: cuint16;
|
||||
freq: cuint16;
|
||||
volume: cuint8;
|
||||
pan: cuint8;
|
||||
loop: cbool;
|
||||
format: cuint8;
|
||||
end;
|
||||
TSoundPlayMsg = SoundPlayMsg;
|
||||
PSoundPlayMsg = ^SoundPlayMsg;
|
||||
|
||||
SoundPsgMsg = record
|
||||
_type: cuint16;
|
||||
freq: cuint16;
|
||||
dutyCycle: cuint8;
|
||||
volume: cuint8;
|
||||
pan: cuint8;
|
||||
end;
|
||||
TSoundPsgMsg = SoundPsgMsg;
|
||||
PSoundPsgMsg = ^SoundPsgMsg;
|
||||
|
||||
MicRecordMsg = record
|
||||
_type: cuint16;
|
||||
buffer: pointer;
|
||||
bufferLength: cuint32;
|
||||
freq: cuint16;
|
||||
format: cuint8;
|
||||
end;
|
||||
TMicRecordMsg = MicRecordMsg;
|
||||
PMicRecordMsg = ^MicRecordMsg;
|
||||
|
||||
MicBufferFullMsg = record
|
||||
_type: cuint16;
|
||||
buffer: pointer;
|
||||
length: cuint32;
|
||||
end;
|
||||
TMicBufferFullMsg = MicBufferFullMsg;
|
||||
PMicBufferFullMsg = ^MicBufferFullMsg;
|
||||
|
||||
|
||||
SystemInputMsg = record
|
||||
_type: cuint16;
|
||||
touch: touchPosition;
|
||||
keys: cuint16;
|
||||
end;
|
||||
TSystemInputMsg = SystemInputMsg;
|
||||
PSystemInputMsg = ^SystemInputMsg;
|
||||
|
||||
{$PACKRECORDS C}
|
||||
{$endif NDS_INTERFACE}
|
||||
|
||||
|
@ -122,6 +122,11 @@ procedure irqInitHandler(handler: TVoidFunctionPointer); cdecl; external;
|
||||
procedure irqInitHandler(handler: pointer); cdecl; external;
|
||||
procedure irqEnable(irq: cuint32); cdecl; external;
|
||||
procedure irqDisable(irq: cuint32); cdecl; external;
|
||||
|
||||
procedure swiIntrWait(waitForSet: cint; flags: cuint32); cdecl; external;
|
||||
procedure swiWaitForVBlank(); cdecl; external;
|
||||
function enterCriticalSection(): cint; inline;
|
||||
procedure leaveCriticalSection(oldIME: cint); inline;
|
||||
{$endif NDS_INTERFACE}
|
||||
|
||||
{$ifdef NDS_IMPLEMENTATION}
|
||||
@ -131,5 +136,19 @@ begin
|
||||
result := (1 shl (n + 3));
|
||||
end;
|
||||
|
||||
function enterCriticalSection(): cint; inline;
|
||||
var
|
||||
oldIME: cint;
|
||||
begin
|
||||
oldIME := REG_IME^;
|
||||
REG_IME^ := 0;
|
||||
result := oldIME;
|
||||
end;
|
||||
|
||||
procedure leaveCriticalSection(oldIME: cint); inline;
|
||||
begin
|
||||
REG_IME^ := oldIME;
|
||||
end;
|
||||
|
||||
{$endif NDS_IMPLEMENTATION}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
{$include helper.inc}
|
||||
{ $include helper.inc}
|
||||
{$include ndstypes.inc}
|
||||
{$include bios.inc}
|
||||
{$include card.inc}
|
||||
|
@ -111,10 +111,8 @@ const
|
||||
REG_WININ : pcuint16 = pointer($4000048);
|
||||
REG_WINOUT : pcuint16 = pointer($400004A);
|
||||
|
||||
REG_MOSAIC : pcuint32 = pointer($400004C);
|
||||
REG_MOSAIC_L : pcuint32 = pointer($400004C);
|
||||
REG_MOSAIC_H : pcuint32 = pointer($400004E);
|
||||
|
||||
MOSAIC_CR = REG_MOSAIC;
|
||||
|
||||
BLEND_CR = REG_BLDCNT;
|
||||
BLEND_AB = REG_BLDALPHA;
|
||||
BLEND_Y = REG_BLDY;
|
||||
@ -171,13 +169,11 @@ const
|
||||
REG_WIN0V_SUB : pcuint16 = pointer($4001044);
|
||||
REG_WIN1V_SUB : pcuint16 = pointer($4001046);
|
||||
REG_WININ_SUB : pcuint16 = pointer($4001048);
|
||||
REG_WINOUT_SUB : pcuint16 = pointer($400104A);
|
||||
REG_WINOUT_SUB : pcuint16 = pointer($400104A);
|
||||
|
||||
REG_MOSAIC_SUB : pcuint32 = pointer($400104C);
|
||||
REG_MOSAIC_L_SUB : pcuint16 = pointer($400104C);
|
||||
REG_MOSAIC_H_SUB : pcuint16 = pointer($400104E);
|
||||
SUB_MOSAIC_CR = REG_MOSAIC_SUB;
|
||||
|
||||
REG_BLDMOD_SUB : pcuint16 = pointer($4001050);
|
||||
REG_BLDMOD_SUB: pcuint16 = pointer($4001050);
|
||||
REG_COLV_SUB : pcuint16 = pointer($4001052);
|
||||
REG_COLY_SUB : pcuint16 = pointer($4001054);
|
||||
|
||||
|
@ -76,15 +76,17 @@ const
|
||||
POWER_3D_CORE : PM_Bits = PM_ARM9_DIRECT or (1 shl 3);
|
||||
POWER_2D_B : PM_Bits = PM_ARM9_DIRECT or (1 shl 9);
|
||||
POWER_SWAP_LCDS: PM_Bits = PM_ARM9_DIRECT or (1 shl 15);
|
||||
POWER_ALL_2D : PM_Bits = PM_ARM9_DIRECT or (1 shl 0) or (1 shl 1) or (1 shl 9);
|
||||
POWER_ALL : PM_Bits = PM_ARM9_DIRECT or (1 shl 0) or (1 shl 1) or (1 shl 9) or (1 shl 3) or (1 shl 2);
|
||||
// POWER_ALL_2D : PM_Bits = PM_ARM9_DIRECT or POWER_LCD or POWER_2D_A or POWER_2D_B;
|
||||
POWER_ALL_2D : PM_Bits = (1 shl 16) or (1 shl 0) or (1 shl 1) or (1 shl 9);
|
||||
// POWER_ALL : PM_Bits = PM_ARM9_DIRECT or POWER_ALL_2D or POWER_3D_CORE or POWER_MATRIX;
|
||||
POWER_ALL : PM_Bits = (1 shl 16) or (1 shl 0) or (1 shl 1) or (1 shl 9) or (1 shl 3) or (1 shl 2);
|
||||
|
||||
procedure sleep(); cdecl; external;
|
||||
|
||||
{$ifdef ARM9}
|
||||
procedure powerOn(bits: PM_Bits); cdecl; external;
|
||||
procedure powerOff(bits: PM_Bits); cdecl; external;
|
||||
procedure ledBlink(bm: PM_LedBlinkMode); cdecl; external;
|
||||
procedure powerOn(bits: cint); cdecl; external;
|
||||
procedure powerOff(bits: cint); cdecl; external;
|
||||
procedure ledBlink(bm: cint); cdecl; external;
|
||||
|
||||
procedure systemMsgHandler(bytes: cint; user_data: pointer); cdecl; external;
|
||||
procedure powerValueHandler(value: cuint32; data: pointer); cdecl; external;
|
||||
@ -143,7 +145,7 @@ function readPowerManagement(reg: cint): cint; inline;
|
||||
|
||||
procedure powerOn(bits: PM_Bits); inline;
|
||||
procedure powerOff(bits: PM_Bits); inline;
|
||||
|
||||
procedure systemShutDown(); inline;
|
||||
procedure readUserSettings(); cdecl; external;
|
||||
{$endif ARM7}
|
||||
|
||||
@ -277,6 +279,11 @@ procedure powerOff(bits: PM_Bits); inline;
|
||||
begin
|
||||
REG_POWERCNT^ := REG_POWERCNT^ and not bits;
|
||||
end;
|
||||
|
||||
procedure systemShutDown(); inline;
|
||||
begin
|
||||
powerOn(PM_SYSTEM_PWR);
|
||||
end;
|
||||
{$endif ARM7}
|
||||
{$endif NDS_IMPLEMENTATION}
|
||||
|
||||
|
@ -86,7 +86,8 @@ const
|
||||
TIMER_DIV_1024 = (3);
|
||||
|
||||
procedure timerStop(channel: cint); inline;
|
||||
|
||||
procedure cpuStartTiming(timer: cuint32); cdecl; external;
|
||||
function cpuEndTiming(): cuint32; cdecl; external;
|
||||
{$endif NDS_INTERFACE}
|
||||
|
||||
|
||||
|
56
rtl/nds/libc.inc
Normal file
56
rtl/nds/libc.inc
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
This file is part of the Free Component Library (FCL)
|
||||
Copyright (c) 1999-2002 by the Free Pascal development team
|
||||
|
||||
BIOS functions unit for Nintendo DS
|
||||
Copyright (c) 2006 by Francesco Lombardi
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
*****************************************************************************}
|
||||
|
||||
function __errno: plongint; cdecl; export;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
function S_ISBLK(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFBLK;
|
||||
end;
|
||||
|
||||
function S_ISCHR(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFCHR;
|
||||
end;
|
||||
|
||||
function S_ISDIR(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFDIR;
|
||||
end;
|
||||
|
||||
function S_ISFIFO(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFIFO;
|
||||
end;
|
||||
|
||||
function S_ISREG(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFREG;
|
||||
end;
|
||||
|
||||
function S_ISLNK(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFLNK;
|
||||
end;
|
||||
|
||||
function S_ISSOCK(m: longint): boolean; inline;
|
||||
begin
|
||||
result := (m and _IFMT) = _IFSOCK;
|
||||
end;
|
199
rtl/nds/libch.inc
Normal file
199
rtl/nds/libch.inc
Normal file
@ -0,0 +1,199 @@
|
||||
{
|
||||
This file is part of the Free Component Library (FCL)
|
||||
Copyright (c) 1999-2002 by the Free Pascal development team
|
||||
|
||||
BIOS functions unit for Nintendo DS
|
||||
Copyright (c) 2006 by Francesco Lombardi
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
*****************************************************************************}
|
||||
|
||||
type
|
||||
time_t = longint;
|
||||
ptime_t = ^time_t;
|
||||
|
||||
Ptm = ^tm;
|
||||
tm = record
|
||||
tm_sec: longint;
|
||||
tm_min: longint;
|
||||
tm_hour: longint;
|
||||
tm_mday: longint;
|
||||
tm_mon: longint;
|
||||
tm_year: longint;
|
||||
tm_wday: longint;
|
||||
tm_yday: longint;
|
||||
tm_isdst: longint;
|
||||
end;
|
||||
|
||||
|
||||
(* Some libc functions *)
|
||||
//function printf(format: Pchar; args: array of const): longint; cdecl; external;
|
||||
function printf(format: Pchar): longint; cdecl; varargs; external;
|
||||
//function sprintf(s: Pchar; format: Pchar; args: array of const): longint; cdecl; external;
|
||||
function sprintf(s: Pchar; format: Pchar): longint; varargs; cdecl; external;
|
||||
//function iprintf(format: Pchar; args: array of const): longint; cdecl; external;
|
||||
function iprintf(format: Pchar): longint; varargs; cdecl; external;
|
||||
//function scanf(format: Pchar; args: array of const): longint; cdecl; external;
|
||||
function scanf(format: Pchar): longint; cdecl; varargs; external;
|
||||
//function sscanf(s: Pchar; format: Pchar; args: array of const): longint; cdecl; external;
|
||||
function sscanf(s: Pchar; format: Pchar): longint; cdecl; varargs; external;
|
||||
function strcmp(s1: Pchar; s2: Pchar): longint; cdecl; external;
|
||||
|
||||
function malloc(size: integer): pointer; cdecl; external;
|
||||
function realloc(ptr: pointer; size: integer): pointer; cdecl; external;
|
||||
procedure free(ptr: pointer); cdecl; external;
|
||||
function memcpy(dest: pointer; src: pointer; n: integer): pointer; cdecl; external;
|
||||
|
||||
function gmtime(timer: ptime_t): ptm; cdecl; external;
|
||||
function time(timer: ptime_t): time_t; cdecl; external;
|
||||
|
||||
type
|
||||
TSort = function (const a, b: pointer): integer;
|
||||
procedure qsort(__base: pointer; __nmemb: integer; __size: integer; __compar: TSort); cdecl; external;
|
||||
|
||||
function __errno: plongint; cdecl; export;
|
||||
|
||||
type
|
||||
_FILE = record
|
||||
firstCluster: longword;
|
||||
length: longword;
|
||||
curPos: longword;
|
||||
curClus: longword; // Current cluster to read from
|
||||
curSect: integer; // Current sector within cluster
|
||||
curByte: integer; // Current byte within sector
|
||||
readBuffer: array [0..511] of byte; // Buffer used for unaligned reads
|
||||
appClus: longword; // Cluster to append to
|
||||
appSect: integer; // Sector within cluster for appending
|
||||
appByte: integer; // Byte within sector for appending
|
||||
read: boolean; // Can read from file
|
||||
write: boolean; // Can write to file
|
||||
append: boolean; // Can append to file
|
||||
inUse: boolean; // This file is open
|
||||
dirEntSector: longword; // The sector where the directory entry is stored
|
||||
dirEntOffset: integer; // The offset within the directory sector
|
||||
end;
|
||||
P_FILE = ^_FILE;
|
||||
|
||||
const
|
||||
SEEK_SET = 0;
|
||||
SEEK_CUR = 1;
|
||||
SEEK_END = 2;
|
||||
|
||||
(*
|
||||
------------------------------------------------------------------------------
|
||||
Directory iterator for mantaining state between dir* calls
|
||||
------------------------------------------------------------------------------
|
||||
*)
|
||||
type
|
||||
DIR_ITER = record
|
||||
device: longint;
|
||||
dirStruct: pointer;
|
||||
end;
|
||||
PDIR_ITER = ^DIR_ITER;
|
||||
|
||||
stat = packed record
|
||||
st_dev: longint;
|
||||
st_ino: longword;
|
||||
st_mode : longword;
|
||||
st_nlink : word;
|
||||
st_uid : word;
|
||||
st_gid : word;
|
||||
st_rdev : longint;
|
||||
st_size : longint;
|
||||
st_atime : longint;
|
||||
|
||||
st_spare1: longint;
|
||||
st_mtime: longint;
|
||||
st_spare2: longint;
|
||||
st_ctime: longint;
|
||||
st_spare3: longint;
|
||||
st_blksize: longint;
|
||||
st_blocks: longint;
|
||||
st_spare4: array [0..1] of longint;
|
||||
end;
|
||||
TStat = stat;
|
||||
PStat = ^stat;
|
||||
|
||||
const
|
||||
_IFMT = 0170000; // type of file
|
||||
_IFDIR = 0040000; // directory
|
||||
_IFCHR = 0020000; // character special
|
||||
_IFBLK = 0060000; // block special
|
||||
_IFREG = 0100000; // regular
|
||||
_IFLNK = 0120000; // symbolic link
|
||||
_IFSOCK = 0140000; // socket
|
||||
_IFIFO = 0010000; // fifo
|
||||
|
||||
S_BLKSIZE = 1024; // size of a block
|
||||
|
||||
S_ISUID = 0004000; // set user id on execution
|
||||
S_ISGID = 0002000; // set group id on execution
|
||||
|
||||
NAME_MAX = 767;
|
||||
|
||||
function S_ISBLK(m: longint): boolean; inline;
|
||||
function S_ISCHR(m: longint): boolean; inline;
|
||||
function S_ISDIR(m: longint): boolean; inline;
|
||||
function S_ISFIFO(m: longint): boolean; inline;
|
||||
function S_ISREG(m: longint): boolean; inline;
|
||||
function S_ISLNK(m: longint): boolean; inline;
|
||||
function S_ISSOCK(m: longint): boolean; inline;
|
||||
|
||||
|
||||
type
|
||||
dirent = record
|
||||
d_ino: longint;
|
||||
d_name: array [0..NAME_MAX] of char;
|
||||
end;
|
||||
PDirent = ^dirent;
|
||||
PPDirent = ^PDirent;
|
||||
|
||||
DIR = record
|
||||
position: longint;
|
||||
dirData: PDIR_ITER;
|
||||
fileData: dirent;
|
||||
end;
|
||||
PDIR = ^DIR;
|
||||
|
||||
(* DIR handling *)
|
||||
function closedir(dirp: PDIR): longint; cdecl; external;
|
||||
function opendir(const dirname: pchar): PDIR; cdecl; external;
|
||||
function readdir(dirp: PDIR): PDirent; cdecl; external;
|
||||
function readdir_r(dirp: PDIR; entry: PDirent; result: PPDirent): longint; cdecl; external;
|
||||
procedure rewinddir(dirp: PDIR); cdecl; external;
|
||||
procedure seekdir(dirp: PDIR; loc: longint); cdecl; external;
|
||||
function telldir(dirp: PDIR): longint; cdecl; external;
|
||||
|
||||
|
||||
function diropen(const path: pchar): PDIR_ITER; cdecl; external;
|
||||
function dirreset(dirState: PDIR_ITER): longint; cdecl; external;
|
||||
function dirnext(dirState: PDIR_ITER; filename: pchar; filestat: Pstat): longint; cdecl; external;
|
||||
function dirclose(dirState: PDIR_ITER): longint; cdecl; external;
|
||||
|
||||
(* File handling *)
|
||||
function fopen(filename: Pchar; modes: Pchar): P_FILE; cdecl; external;
|
||||
function fread(ptr: pointer; size: longint; n: longint; stream: P_FILE): longint; cdecl; external;
|
||||
function fread(var ptr; size: longint; n: longint; var stream: _FILE): longint; cdecl; external;
|
||||
function fwrite(ptr: pointer; size: longint; n: longint; s: P_FILE): longint; cdecl; external;
|
||||
function fwrite(var ptr; size: longint; n: longint; var s: _FILE): longint; cdecl; external;
|
||||
function ftell(stream: P_FILE): longint; cdecl; external;
|
||||
function ftell(var stream: _FILE): longint; cdecl; external;
|
||||
function fseek(stream: P_FILE; off: longint; whence: longint): longint; cdecl; external;
|
||||
function fseek(var stream: _FILE; off: longint; whence: longint): longint; cdecl; external;
|
||||
function fclose(stream: P_FILE): longint; cdecl; external;
|
||||
function fclose(var stream: _FILE): longint; cdecl; external;
|
||||
function isatty(fildes: longint): longint; cdecl; external;
|
||||
function fileno(para1: P_FILE): longint; cdecl; external;
|
||||
function fileno(var para1: _FILE): longint; cdecl; external;
|
||||
function fstat(fildes: longint; buf: PStat): longint; cdecl; external;
|
||||
function fstat(fildes: longint; var buf: TStat): longint; cdecl; external;
|
||||
function _stat(__file:Pchar; var __buf:Tstat):longint; cdecl; external name 'stat';
|
||||
function ftruncate(fildes: longint; len: longint): longint; cdecl; external;
|
||||
function unlink(path: Pchar): longint; cdecl; external;
|
||||
function rename(para1: Pchar; para2: Pchar): longint; cdecl; external;
|
@ -35,4 +35,3 @@ procedure AssignDevice(const FIOD: TFileIODevice);
|
||||
begin
|
||||
FileIODevice := FIOD;
|
||||
end;
|
||||
|
||||
|
@ -14,70 +14,19 @@
|
||||
|
||||
*****************************************************************************}
|
||||
|
||||
(*
|
||||
type
|
||||
TStat = packed record
|
||||
st_dev: qword;
|
||||
__pad1: word;
|
||||
__align_pad1: word;
|
||||
st_ino: dword;
|
||||
st_mode : dword;
|
||||
st_nlink : dword;
|
||||
st_uid : dword;
|
||||
st_gid : dword;
|
||||
st_rdev : qword;
|
||||
__pad2 : word;
|
||||
__align_pad2 : word;
|
||||
st_size : longint;
|
||||
st_blksize : longint;
|
||||
st_blocks : longint;
|
||||
st_atime : longint;
|
||||
__unused1 : dword;
|
||||
st_mtime : longint;
|
||||
__unused2 : dword;
|
||||
st_ctime : longint;
|
||||
__unused3 : dword;
|
||||
__unused4 : dword;
|
||||
__unused5 : dword;
|
||||
end;
|
||||
PStat = ^TStat;
|
||||
*)
|
||||
(* libc file handling types and routines *)
|
||||
(*
|
||||
_FILE = record
|
||||
firstCluster: longword;
|
||||
length: longword;
|
||||
curPos: longword;
|
||||
curClus: longword; // Current cluster to read from
|
||||
curSect: integer; // Current sector within cluster
|
||||
curByte: integer; // Current byte within sector
|
||||
readBuffer: array [0..511] of byte; // Buffer used for unaligned reads
|
||||
appClus: longword; // Cluster to append to
|
||||
appSect: integer; // Sector within cluster for appending
|
||||
appByte: integer; // Byte within sector for appending
|
||||
read: boolean; // Can read from file
|
||||
write: boolean; // Can write to file
|
||||
append: boolean; // Can append to file
|
||||
inUse: boolean; // This file is open
|
||||
dirEntSector: longword; // The sector where the directory entry is stored
|
||||
dirEntOffset: integer; // The offset within the directory sector
|
||||
end;
|
||||
P_FILE = ^_FILE;
|
||||
*)
|
||||
|
||||
type
|
||||
TDoOpen = procedure (var f; p: pchar; flags: longint);
|
||||
TDoClose = procedure (handle: THandle);
|
||||
TDoWrite = function (h: THandle; addr: pointer; len: longint): longint;
|
||||
TDoRead = function (h: THandle; addr: pointer; len: longint): longint;
|
||||
TDoSeek = procedure (handle: THandle; pos: longint);
|
||||
TDoSeekend = function (handle: THandle): longint;
|
||||
TDoErase = procedure (p: pchar);
|
||||
TDoRename = procedure (p1, p2: pchar);
|
||||
TDoFilepos = function (handle: THandle): longint;
|
||||
TDoFilesize = function (handle: THandle): longint;
|
||||
TDoTruncate = procedure (handle: THandle; pos: longint);
|
||||
TDoIsdevice = function (handle: THandle): boolean;
|
||||
TDoOpen = procedure (var f; p: pchar; flags: longint);
|
||||
TDoClose = procedure (handle: THandle);
|
||||
TDoWrite = function (h: THandle; addr: pointer; len: longint): longint;
|
||||
TDoRead = function (h: THandle; addr: pointer; len: longint): longint;
|
||||
TDoSeek = procedure (handle: THandle; pos: longint);
|
||||
TDoSeekend = function (handle: THandle): longint;
|
||||
TDoErase = procedure (p: pchar);
|
||||
TDoRename = procedure (p1, p2: pchar);
|
||||
TDoFilepos = function (handle: THandle): longint;
|
||||
TDoFilesize = function (handle: THandle): longint;
|
||||
TDoTruncate = procedure (handle: THandle; pos: longint);
|
||||
TDoIsdevice = function (handle: THandle): boolean;
|
||||
|
||||
TFileIO = packed record
|
||||
DoOpen : TDoOpen;
|
||||
@ -95,7 +44,6 @@ type
|
||||
end;
|
||||
PFileIO = ^TFileIO;
|
||||
|
||||
|
||||
TDoMkdir = procedure (const s: string);
|
||||
TDoRmdir = procedure (const s: string);
|
||||
TDoChdir = procedure (const s: string);
|
||||
@ -122,10 +70,8 @@ function IsARM9(): boolean;
|
||||
procedure AssignDevice(const FIOD: TFileIODevice);
|
||||
|
||||
var
|
||||
FileIODevice: TFileIODevice =
|
||||
(
|
||||
FileIO:
|
||||
(
|
||||
FileIODevice: TFileIODevice = (
|
||||
FileIO: (
|
||||
DoOpen: nil;
|
||||
DoClose: nil;
|
||||
DoWrite: nil;
|
||||
@ -138,14 +84,11 @@ var
|
||||
DoFilesize: nil;
|
||||
DoTruncate: nil;
|
||||
DoIsdevice: nil;
|
||||
);
|
||||
DirIO:
|
||||
(
|
||||
);
|
||||
DirIO: (
|
||||
DoMkdir: nil;
|
||||
DoRmdir: nil;
|
||||
DoChdir: nil;
|
||||
DoGetdir: nil;
|
||||
);
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ interface
|
||||
{$i systemh.inc}
|
||||
{$i ndsbiosh.inc}
|
||||
{$i ndsh.inc}
|
||||
{$i libch.inc}
|
||||
|
||||
|
||||
|
||||
@ -92,6 +93,7 @@ implementation
|
||||
{$i system.inc}
|
||||
{$i ndsbios.inc}
|
||||
{$i nds.inc}
|
||||
{$i libc.inc}
|
||||
|
||||
|
||||
|
||||
@ -182,8 +184,7 @@ begin
|
||||
{ OS specific startup }
|
||||
|
||||
{ Set up signals handlers }
|
||||
if IsARM9 then
|
||||
fpc_cpucodeinit;
|
||||
fpc_cpucodeinit;
|
||||
|
||||
{ Setup heap }
|
||||
InitHeap;
|
||||
|
Loading…
Reference in New Issue
Block a user