Calculator Community > ASM

[8X+] [B&W] universal snacks

(1/2) > >>

the_mad_joob:
Welcome.

All routines are compatible with all 8X+ B&W models.
Those are pretty low-level, so except for a few, no system code is used.
You guessed it, optimisation is clearly towards speed.
Each file includes deep documentation, please read everything before using.
Don't hesitate to ask if something is unclear.

Enjoy =]



flash.zip

flash\flashlock.z80
flash\flashmanuf.z80
flash\flashsize.z80
flash\flashunlock.z80
flash\romwrite1.z80
flash\romwritex.z80
flash\sectcheck.z80
flash\secterase.z80

lcd.zip

lcd\font.png
lcd\font.z80
lcd\lcdcfg.z80
lcd\lcddisp.z80
lcd\lcddispchr.z80
lcd\lcddispstr.z80
lcd\lcdfill.z80
lcd\lcdinv.z80
lcd\lcdinvchr.z80
lcd\lcdinvcur.z80
lcd\lcdinvstr.z80
lcd\lcdsave.z80

memory.zip

memory\ramlock.z80
memory\ramsize.z80
memory\ramunlock.z80
memory\romlock.z80
memory\romsize.z80
memory\romunlock.z80

utility.zip

utility\keyboard.inc
utility\battcheck.z80
utility\bootver.z80
utility\intdefaults.z80
utility\intdisable.z80
utility\keybscan.z80
utility\poweroff.z80
utility\sysver.z80
utility\usbinfo.z80

E37:
Those are pretty neat especially the last one! I wish I had an excuse to use them.
Why don't you include a faster version of the flash to ram bcall while you are at it? It should be pretty easy since all you have to do is swap the flash bank into $4000-$4FFF and ldir it to ram and swap the page when needed.

the_mad_joob:

--- Quote from: E37 on June 28, 2019, 08:15:20 pm ---Those are pretty neat especially the last one! I wish I had an excuse to use them.
Why don't you include a faster version of the flash to ram bcall while you are at it? It should be pretty easy since all you have to do is swap the flash bank into $4000-$4FFF and ldir it to ram and swap the page when needed.

--- End quote ---
Yeah, the day i coded the last one, i truly fell in love with conditionnal ret instructions, as a freakin' fast way to exit very low level loops.
About the routine you're talking about, it's not what i would exactly call flash-related, since you're writing to ram, so i'm not sure if it fits in this thread.
Also, i'm pretty sure plenty of routines like that can already be found.

TIfanx1999:

--- Quote from: E37 on June 28, 2019, 08:15:20 pm ---Those are pretty neat especially the last one! I wish I had an excuse to use them.

--- End quote ---
^This. Nice work!

Xeda112358:
Thanks a bunch, I might think a way to use this! @E37 : there are some pretty decent existing flash-to-RAM routines.
A classic way to increment HL through RAM pages is to do something like:

--- Code: ---    inc l
    call z,incHLmem1
...
...
incHLmem1:
  inc h
  ret po
  ld h,a
  in a,(6)
  inc a
  out (6),a
  ld a,h
  ld h,40h
  ret

--- End code ---
That method averages between 14cc and 15cc and advances the page as needed. You need to initialize by swapping in the correct page, though.

Here is my take on a flash-to-RAM routine, though:

--- Code: ---FlashToRAM:
;Inputs: Same as LDIR, but A is the page number.
;Outputs:
;    Same as LDIR, except A is the ending page.
;
;Speed:
;RAM: 21+21n
;ARC, but no boundary: 114+21n
;Arc, on two pages: 21n+269
;Arc, on three pages: 21n+355
  or a
  jp z,ReadRAM
  out (6),a
  add hl,bc
;  jr c,read_from_Arc_blocks   ;if you need this, you probably need a different routine. This implies that writing will eventually reach the 0x0000 to 0x3FFF range.
  jp p,read_from_ARC_noboundary
read_from_Arc_blocks:
;If we make it here, we know that we cross a page boundary (or in one case, we just reach it and need to return on the next page).
;We will read in blocks to avoid checking page boundaries
;To do so, we first read up to 0x8000 - HL bytes
  xor a
  sbc hl,bc
  sub l \ ld l,a
  ld a,$80 \ sbc a,h \ ld h,a
  ;now we will subtract BC-HL  -> BC
  ld a,c \ sub l \ ld c,a
  ld a,b \ sbc a,h \ ld b,a
  push bc
  ld b,h
  ld c,l
  xor a \ sub l \ ld l,a
  ld a,$80 \ sbc a,h \ ld h,a
  ;now we read the first block
block_loop:
  ldir
  ;now we increment the page and continue reading from $4000
  in a,(6)
  inc a
  out (6),a
  ld h,40h
  pop bc
  ;if BC<$4000, just LDIR the rest
  ld a,b
  sub h
  jr c,read_from_RAM
  ld b,a
  push bc
  ld b,h
  ld c,l
  jp block_loop
read_from_ARC_noboundary:
;  or a     ;already reset
  sbc hl,bc
read_from_RAM:
  ldir
  in a,(6)
  ld b,a
page_restore = $+1
  ld a,0
  out (6),a
  ld a,b
  ld b,c
  ret
ReadRAM:
  ldir
  ret

--- End code ---
It needs to run in RAM and uses SMC.

Navigation

[0] Message Index

[#] Next page

Go to full version