From 9af4168ae246d40a78e3b7962061b487b03ca303 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 2 Apr 2024 22:17:51 +0200 Subject: [PATCH] cx16: added diskio.fastmode() to select the fast serial disk mode for the SD card --- compiler/res/prog8lib/cx16/diskio.p8 | 11 +++++++++++ examples/cx16/chunkedfile/demo.p8 | 1 + examples/cx16/diskspeed.p8 | 14 +++++++++----- examples/cx16/pcmaudio/stream-wav.p8 | 1 + examples/cx16/showbmx.p8 | 1 + 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/compiler/res/prog8lib/cx16/diskio.p8 b/compiler/res/prog8lib/cx16/diskio.p8 index afc782221..afa2639eb 100644 --- a/compiler/res/prog8lib/cx16/diskio.p8 +++ b/compiler/res/prog8lib/cx16/diskio.p8 @@ -32,6 +32,17 @@ diskio { cbm.CHKOUT(WRITE_IO_CHANNEL) } + sub fastmode(ubyte mode) { + ; -- set fast serial mode (0=none, 1=auto_tx, 2=fast writes, 3=both) for the SD card + list_filename[0] = 'u' + list_filename[1] = '0' + list_filename[2] = '>' + list_filename[3] = 'b' + list_filename[4] = mode | $30 + list_filename[5] = 0 + send_command(list_filename) + } + sub directory() -> bool { ; -- Prints the directory contents to the screen. Returns success. diff --git a/examples/cx16/chunkedfile/demo.p8 b/examples/cx16/chunkedfile/demo.p8 index 2a91fa327..88deea080 100644 --- a/examples/cx16/chunkedfile/demo.p8 +++ b/examples/cx16/chunkedfile/demo.p8 @@ -9,6 +9,7 @@ main { uword duration ubyte[256] bonkbuffer + ;; diskio.fastmode(1) set_screen_mode() cbm.SETTIM(0,0,0) diff --git a/examples/cx16/diskspeed.p8 b/examples/cx16/diskspeed.p8 index 02befc738..af51e716b 100644 --- a/examples/cx16/diskspeed.p8 +++ b/examples/cx16/diskspeed.p8 @@ -8,8 +8,6 @@ main { const ubyte HIRAM_START_BANK = 4 uword large = memory("large", 20000, 256) - bool verify = false - ubyte[256] buffer = 0 to 255 uword @zp buf_ptr @@ -17,10 +15,11 @@ main { txt.print("\n\ndisk benchmark on drive 8.\n") txt.print("with verification? y/n: ") - cx16.r0L = cbm.CHRIN() + bool verify = cbm.CHRIN()=='y' + txt.print("\nfast serial mode r+w? y/n: ") + bool fastserial = cbm.CHRIN()=='y' txt.nl() - if cx16.r0L=='y' { - verify=true + if verify { ; fill the buffers with random data, and calculate the checksum for cx16.r0 in 0 to 19999 { large[cx16.r0] = math.rnd() @@ -33,6 +32,11 @@ main { uword crc32_h = cx16.r15 } + if fastserial + diskio.fastmode(3) + else + diskio.fastmode(0) + test_save() test_save_blocks() test_load_hiram() diff --git a/examples/cx16/pcmaudio/stream-wav.p8 b/examples/cx16/pcmaudio/stream-wav.p8 index cb5555249..446cf60c8 100644 --- a/examples/cx16/pcmaudio/stream-wav.p8 +++ b/examples/cx16/pcmaudio/stream-wav.p8 @@ -29,6 +29,7 @@ main { ubyte vera_rate sub start() { + ;; diskio.fastmode(1) txt.print("name of .wav file to play on drive 8: ") while 0==txt.input_chars(MUSIC_FILENAME) { ; until user types a name... diff --git a/examples/cx16/showbmx.p8 b/examples/cx16/showbmx.p8 index 7d9a7348b..ed944032f 100644 --- a/examples/cx16/showbmx.p8 +++ b/examples/cx16/showbmx.p8 @@ -12,6 +12,7 @@ main { str filename = "?"*40 repeat { + ;; diskio.fastmode(1) txt.print("\nenter bmx image filename: ") if txt.input_chars(&filename)!=0 {