mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Implement READFILE function (#1759)
This commit is contained in:
24
test/asm/readfile-binary.asm
Normal file
24
test/asm/readfile-binary.asm
Normal file
@@ -0,0 +1,24 @@
|
||||
section "tilemap", rom0
|
||||
/*
|
||||
input:
|
||||
$20
|
||||
$01 $03 $05 $07 $09
|
||||
$02 $04 $06 $08 $10
|
||||
$00 $de $01 $df $80
|
||||
5
|
||||
*/
|
||||
def tilemap equs readfile("readfile-binary.inc.bin")
|
||||
def area = bytelen(#tilemap) - 2
|
||||
def offset = strbyte(#tilemap, 0)
|
||||
def width = strbyte(#tilemap, area + 1)
|
||||
db width, area / width
|
||||
for idx, area
|
||||
db strbyte(#tilemap, idx + 1) + offset
|
||||
endr
|
||||
/*
|
||||
output:
|
||||
5, 3
|
||||
$21 $23 $25 $27 $29
|
||||
$22 $24 $26 $28 $30
|
||||
$20 $fe $21 $ff $a0
|
||||
*/
|
||||
BIN
test/asm/readfile-binary.inc.bin
Normal file
BIN
test/asm/readfile-binary.inc.bin
Normal file
Binary file not shown.
1
test/asm/readfile-binary.out.bin
Normal file
1
test/asm/readfile-binary.out.bin
Normal file
@@ -0,0 +1 @@
|
||||
!#%')"$&(0 <20>!<21><>
|
||||
2
test/asm/readfile-nonexist.asm
Normal file
2
test/asm/readfile-nonexist.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
def s equs readfile("readfile-nonexist.inc")
|
||||
assert strlen(#s) == 0
|
||||
3
test/asm/readfile-nonexist.err
Normal file
3
test/asm/readfile-nonexist.err
Normal file
@@ -0,0 +1,3 @@
|
||||
error: readfile-nonexist.asm(1):
|
||||
Error opening READFILE file 'readfile-nonexist.inc': No such file or directory
|
||||
Assembly aborted with 1 error!
|
||||
5
test/asm/readfile.asm
Normal file
5
test/asm/readfile.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
def s equs readfile("readfile.inc")
|
||||
println strupr(#s) ++ "!"
|
||||
|
||||
redef s equs readfile("readfile.inc", 5)
|
||||
println strrpl(#s, "l", "w") ++ "?"
|
||||
1
test/asm/readfile.inc
Normal file
1
test/asm/readfile.inc
Normal file
@@ -0,0 +1 @@
|
||||
hello world
|
||||
2
test/asm/readfile.out
Normal file
2
test/asm/readfile.out
Normal file
@@ -0,0 +1,2 @@
|
||||
HELLO WORLD!
|
||||
hewwo?
|
||||
Reference in New Issue
Block a user