mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
added diskio.f_read_exact()
This commit is contained in:
parent
45bfecee73
commit
e0d2b60d8b
@ -227,13 +227,15 @@ close_end:
|
||||
return false
|
||||
}
|
||||
|
||||
sub f_read(uword bufferpointer, uword buffersize) -> uword {
|
||||
sub f_read(uword bufferpointer, uword num_bytes) -> uword {
|
||||
; -- read from the currently open file, up to the given number of bytes.
|
||||
; returns the actual number of bytes read. (checks for End-of-file and error conditions)
|
||||
if not iteration_in_progress
|
||||
return 0
|
||||
|
||||
uword actual = 0
|
||||
void c64.CHKIN(11) ; use #11 as input channel again
|
||||
repeat buffersize {
|
||||
repeat num_bytes {
|
||||
ubyte data = c64.CHRIN()
|
||||
@(bufferpointer) = data
|
||||
bufferpointer++
|
||||
@ -247,6 +249,19 @@ close_end:
|
||||
return actual
|
||||
}
|
||||
|
||||
sub f_read_exact(uword bufferpointer, uword num_bytes) {
|
||||
; -- read from the currently open file, the given number of bytes. File must contain enough data!
|
||||
; doesn't check for error conditions or end of file, to make the read as fast as possible.
|
||||
if not iteration_in_progress
|
||||
return
|
||||
|
||||
void c64.CHKIN(11) ; use #11 as input channel again
|
||||
repeat num_bytes {
|
||||
@(bufferpointer) = c64.CHRIN()
|
||||
bufferpointer++
|
||||
}
|
||||
}
|
||||
|
||||
sub f_close() {
|
||||
; -- end an iterative file loading session (close channels).
|
||||
if iteration_in_progress {
|
||||
|
@ -45,7 +45,7 @@ iff_module {
|
||||
|
||||
while read_chunk_header() {
|
||||
if chunk_id == "bmhd" {
|
||||
void diskio.f_read(buffer, chunk_size_lo)
|
||||
diskio.f_read_exact(buffer, chunk_size_lo)
|
||||
width = mkword(buffer[0], buffer[1])
|
||||
height = mkword(buffer[2], buffer[3])
|
||||
num_planes = buffer[8]
|
||||
@ -53,7 +53,7 @@ iff_module {
|
||||
compression = buffer[10]
|
||||
}
|
||||
else if chunk_id == "camg" {
|
||||
void diskio.f_read(buffer, chunk_size_lo)
|
||||
diskio.f_read_exact(buffer, chunk_size_lo)
|
||||
camg = mkword(buffer[2], buffer[3])
|
||||
if camg & $0800 {
|
||||
txt.print("ham mode not supported!\n")
|
||||
@ -62,13 +62,13 @@ iff_module {
|
||||
}
|
||||
else if chunk_id == "cmap" {
|
||||
have_cmap = true
|
||||
void diskio.f_read(&cmap, chunk_size_lo)
|
||||
diskio.f_read_exact(&cmap, chunk_size_lo)
|
||||
}
|
||||
else if chunk_id == "crng" {
|
||||
; DeluxePaint color cycle range
|
||||
if not cycle_ccrt {
|
||||
cycle_crng = true
|
||||
void diskio.f_read(buffer, chunk_size_lo)
|
||||
diskio.f_read_exact(buffer, chunk_size_lo)
|
||||
cycle_rates[num_cycles] = mkword(buffer[2], buffer[3])
|
||||
cycle_rate_ticks[num_cycles] = 1
|
||||
cycle_lows[num_cycles] = buffer[6]
|
||||
@ -82,7 +82,7 @@ iff_module {
|
||||
; Graphicraft color cycle range
|
||||
if not cycle_crng {
|
||||
cycle_ccrt = true
|
||||
void diskio.f_read(buffer, chunk_size_lo)
|
||||
diskio.f_read_exact(buffer, chunk_size_lo)
|
||||
ubyte direction = buffer[1]
|
||||
if direction {
|
||||
; delay_sec = buffer[4] * 256 * 256 * 256 + buffer[5] * 256 * 256 + buffer[6] * 256 + buffer[7]
|
||||
@ -143,9 +143,9 @@ iff_module {
|
||||
|
||||
sub skip_chunk() {
|
||||
repeat lsb(chunk_size_hi)*8 + (chunk_size_lo >> 13)
|
||||
void diskio.f_read(scanline_data_ptr, $2000)
|
||||
diskio.f_read_exact(scanline_data_ptr, $2000)
|
||||
|
||||
void diskio.f_read(scanline_data_ptr, chunk_size_lo & $1fff)
|
||||
diskio.f_read_exact(scanline_data_ptr, chunk_size_lo & $1fff)
|
||||
}
|
||||
|
||||
sub make_ehb_palette() {
|
||||
@ -190,9 +190,9 @@ iff_module {
|
||||
ubyte interlaced = (camg & $0004) != 0
|
||||
uword y
|
||||
for y in 0 to height-1 {
|
||||
void diskio.f_read(scanline_data_ptr, interleave_stride)
|
||||
diskio.f_read_exact(scanline_data_ptr, interleave_stride)
|
||||
if interlaced
|
||||
void diskio.f_read(scanline_data_ptr, interleave_stride)
|
||||
diskio.f_read_exact(scanline_data_ptr, interleave_stride)
|
||||
cx16.FB_cursor_position(offsetx, offsety+y)
|
||||
planar_to_chunky_scanline()
|
||||
}
|
||||
|
@ -11,13 +11,11 @@ koala_module {
|
||||
if diskio.f_open(8, filenameptr) {
|
||||
uword size = diskio.f_read(load_location, 2) ; skip the first 2 bytes (load address)
|
||||
if size==2 {
|
||||
size = diskio.f_read(load_location, 10001)
|
||||
if size == 10001 {
|
||||
; set a better C64 color palette, the Cx16's default is too saturated
|
||||
c64colors.set_palette_pepto()
|
||||
convert_koalapic()
|
||||
load_ok = true
|
||||
}
|
||||
diskio.f_read_exact(load_location, 10001)
|
||||
; set a better C64 color palette, the Cx16's default is too saturated
|
||||
c64colors.set_palette_pepto()
|
||||
convert_koalapic()
|
||||
load_ok = true
|
||||
}
|
||||
diskio.f_close()
|
||||
}
|
||||
|
@ -11,14 +11,24 @@ main {
|
||||
|
||||
; TODO asmsub version generates LARGER CODE , why is this?
|
||||
sub vpoke(ubyte bank, uword address, ubyte value) {
|
||||
|
||||
%asm {{
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub vpokeasm(uword address @R0, ubyte bank @A, ubyte value @Y) {
|
||||
|
||||
%asm {{
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
sub start () {
|
||||
txt.chrout('!')
|
||||
ubyte bank = 1
|
||||
uword address = 1000
|
||||
ubyte value = 123
|
||||
bank++
|
||||
vpoke(bank, address, value)
|
||||
vpokeasm(address, bank, value)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user