Calculator Community > ASM

8X+[SE] - universal snacks

(1/3) > >>

the_mad_joob:
INTRODUCTION

This is a pack of routines and various files i've built over the years.
I can't say i haven't been inspired by others, so some stuff expands|fixes existing work.
Optimisation is mostly towards speed, and system code is used as rarely as possible.
Each file includes deep documentation.



COMPATIBILITY

Except if specified, all TI-8X+ models (monochrome screen) are supported.
Same goes for official systems and boot codes.
Everything else should be considered unsupported.



DISCLAIMER

For each routine, you are expected to follow EVERYTHING that's in the "IN" section.
Also, when there's a "WARNING" section, it's to be taken seriously.
If something is unclear, feel free to ask there BEFORE using : https://www.omnimaga.org/asm-language/flash-snacks/



NOTE ABOUT "OUT" SECTIONS

? means a register is to be considered destroyed.

Unlisted registers are unchanged, except for :
pc,r : always destroyed
af',bc',de',hl' : unchanged if interrupts disabled beforehand | destroyed otherwise

When the f register is detailed, each bit can be :
0 : zero
1 : one
X : variable-known (see "flags")
? : variable-unknown (destroyed)



CONTENT & OVERVIEW

keyboard.inc : keyboard include file
ti83plus.inc : ultimate TI-83+|TI-83+SE|TI-84+|TI-84+SE include file

font_large_custom.png : preview of what's in font_large_custom.z80
font_large_system.png : system 6x8p character font preview (2.53+)

1_character_tokens.txt : token>character reference table for all valid 1-character-long tokens
READ.txt : this file
system_ram_structure.txt : system ram structure summary

arcpages.z80 : Identifies the reference pages of the archive.
battcheck.z80 : Checks batteries.
bootver.z80 : Identifies the boot code version.
cpirnc.z80 : Similar to cpir, but additionally halts if a bank edge is reached.
cpirz.z80 : Similar to cpir, but instead halts if the specified byte isn't found.
cpirznc.z80 : Similar to cpir, but instead halts if the specified byte isn't found, and additionally halts if a bank edge is reached.
flashlock.z80 : Locks the flash chip.
flashmanuf.z80 : Identifies the flash chip manufacturer.
flashunlock.z80 : Unlocks the flash chip.
font_large_custom.z80 : Custom 6x8p character font matching ASCII|ISO-8859-1|CP-1252.
guiselect.z80 : Provides interaction with a simple 6x8p-text-based option selection GUI, using a custom cursor.
intdefault.z80 : Sets all hardware interrupts to the default system configuration.
intdisable.z80 : Disables and acknowledges all hardware interrupts.
keybcheck.z80 : Checks if at least one key is pressed, and if it's [ON].
keybdebounce.z80 : Waits long enough for released keys to stop bouncing.
keybscan.z80 : Scans the whole keyboard, [ON] key excepted.
lcddispbuf.z80 : Displays the content of a custom fullscreen buffer.
lcddispchr.z80 : Displays a 6x8p character, using a custom font.
lcddispstr.z80 : Displays a string of 6x8p characters, using a custom font.
lcddisptxt.z80 : Displays the content of a custom fullscreen text buffer, using a custom 6x8p character font.
lcdfill.z80 : Fills the screen with the same byte, mostly used to clear all pixels.
lcdmode.z80 : LCD mode configuration.
lcdsavebuf.z80 : Stores the display to a custom fullscreen buffer in RAM.
poweroff.z80 : Turns off the calculator, and waits for an [ON] key press.
prgmedit.z80 : Exits, opens the program editor for the specified program, and sets the cursor to the specified location.
r16strdec.z80 : Converts a 16-bit value to a decimal character string, and writes it to RAM.
r8strbin.z80 : Converts an 8-bit value to a binary character string, and writes it to RAM.
r8strdec.z80 : Converts an 8-bit value to a decimal character string, and writes it to RAM.
r8strhex.z80 : Converts an 8-bit value to a hexadecimal character string, and writes it to RAM.
ramlock.z80 : Sets RAM execution permission to the system default configuration.
ramsize.z80 : Identifies the physical RAM size.
ramunlock.z80 : Makes all RAM executable.
romlock.z80 : Sets ROM execution permission to the system default configuration.
romsize.z80 : Identifies the physical ROM size.
romunlock.z80 : Makes all ROM executable.
romwrite1.z80 : Writes a byte to ROM.
romwritex.z80 : Similar to ldir, but instead writes to ROM, and additionally halts if a bank edge is reached.
secterase.z80 : Erases a sector.
sectstate.z80 : Checks a sector for protection against write|erase operations.
strdelz.z80 : Replaces the potential leading zeros of the specified character string in RAM by spaces.
sysver.z80 : Identifies the system version.
usbinfo.z80 : Identifies if USB is available, and its revision type.

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