Z80 Assembly programming for the TI-83

The TI-83 is a bit of an oddity... with a full blown Z80 and large keyboard, it's a great little handheld - but with it's slow screen refresh it's not exactly what you'll want to program games on!

Still, as one of the longest running z80 platforms, it deserves a lot of respect!
Cpu 6mhz Z80
Ram 32k
Resolution   
96x64 2 color   12x8 chars in 8x8 mode
16x10.6 in 6x6 mode
Sound chip NONE!
Chibiakumas Tutorials:

Lesson H7- Hello World on the TI-83
   
Lesson P1 - Basic Firmware Text functions

Lesson P5 - Bitmap graphics on the TI-83 and MSX

Lesson P7 - Keyreading on the MSX, Enterprise and TI-83



IY register

The IY register is used by the operating system... so it's probably best to leave it alone!

bin28xp

If you want to convert a binary to a valid program you can run on your TI, you need to convert it to an 8xp file.

We can use bin28xp to do this, I did not write it, however there was a bug in the original which meant it corrupted larger files, you can get my modified version here

Ports

OUT PORT Function Bits Details
&00 Link

&01 Keyboard

(Out=Row Select / IN = Key results)
&02 Status Port/Interrupt Acknowledge

&03 Interrupt Mask

&04 Memory Map / Interrupt

&05 RAM Page(SE) Port 16 Config/Link Assist(83+)

&06 Memory Page A

&07 Memory Page B

&08 Link Assist Enable

&09 Link Assist Status/CPU Speed 0 Signaling Rate

&0A Link Assist Input Buffer/CPU Speed 1 Signaling Rate

&0B CPU Speed 2 Signaling Rate

&0C CPU Speed 3 Signaling Rate

&0D Link Assist Output Buffer

&0E MemA High Flash Address

&0F MemB High Flash Address

&10 LCD Command / Status Port %BSDR--YI B=Busy S=Size(6/8 pixel)
D=DisplayOn R=Reset
Y=XY auto I=AutoDec/Inc
&11 LCD Data %DDDDDDDD 
/ %--DDDDDD
Pixel Data (8/6 bits)
&12 LCD Command Mirror

&13 LCD Data Mirror

&14 Flash Control

&15 ASIC Version

&16 Flash Page Exclusion

&18-1F MD5 Calculation

&20 CPU Speed Port

&21 Flash Size/ RAM Size

&22 Flash Lower Limit

&23 Flash Upper Limit

&24 Flash Execution Limits High Bit

&25 RAM Execution Lower Limit

&26 RAM Execution Upper Limit

&27 Block Memory Mapping C000h

&28 Block Memory Mapping 8000h

&29 LCD Delay (6 MHz)

&2A LCD Delay(15 MHz)

&2B LCD Delay(15 MHz)(02)

&2C LCD Delay(15 MHz)(03)

&2D 32768Hz Crystal Control

&2E Memory Access Delay

&2F LCD Wait Delay

&30-38 Timers

&39 GPIO Configuration

&3A GPIO Read/Write

&40 Clock Control

&41-44 Clock Set

&45-48 Clock Read

&4A D- Control

&4C USB Controller Status

&4D USB Line State

&54 USB Controller Control

&55 USB Interrupt State

&56 USB Line Events

&57 USB Line Event Mask

&5A USB Presentation Link Port Mirroring Enable

&5B USB Protocol Interrupt Enable

&60-7F 40-5F Mirrors

&80 USB Device Address

&82 USB Write-Pipe Events

&83 USB Write-Pipe Events (continued)

&84 USB Read-Pipe Events

&85 USB Read-Pipe Events (continued)

&86 USB Miscellaneous Events

&87 USB Output-Enabled Pipes

&88 USB Output-Enabled Pipes (continued)

&89 USB Input-Enabled Pipes

&8A USB Input-Enabled Pipes (continued)

&8B USB Events Mask

&8C-8D USB Frame Counter

&8E USB Pipe Number

&8F VBus Control

&90 USB Write Packet Size

&91 USB Write Command/Status

&93 USB Read Packet Size

&96 USB Data-Received Counter

&98 USB Write Endpoint Type/Address

&9A USB Read Endpoint Type/Address

Graphics Commands

Command (OUT to &10) Action
&00 Configure six bits per word
&01 Configure eight bits per word
&02 Turn off
&03 Turn on
&04 X auto-decrement (X is Down the screen)
&05 X auto-increment (X is Down the screen)
&06 Y auto-decrement (Y is Across the screen)
&07 Y auto-increment (Y is Across the screen)
&08-&0B Power supply enhancement. &08 is lowest.
&10-&13 Power supply level. &10 is lowest.
&14-&17 Unknown
&18 test mode
&19-&1B Unknown
&1C-&1F Enter test mode
&20-&33 Set Horizontal column nn for next write (Out data to port &11)
&34-&3F Unknown
&40-&7F Set Z-address
&80-&BF Set Vertical row nn for next write (Out data to port &11)
&C0-&FF Set contrast

Memory Map

Address Function
&0000-3FFF Flash Page 0
&4000-7FFF Memory Bank A (MemA)
&8000-BFFF Memory Bank B (MemB) - Program runs from &9D95
&C000-FFFF RAM Page 0

Keyreading on the TI-83

The keyboard is connected to port 1 on the TI, we select the row, and read the data back using this port,
We write this data out, then read in the line contents, and save them to the array

Row
Out &1
IN &1
bit 7   bit 6     bit 5     bit 4   bit 3 bit 2 bit 1 bit 0
%10111111 Del Mode 2nd Y= Window ZOOM Trace Graph
%11011111 Alpha Math x-1 x2 Log Ln Sto
%11101111 X, T, θ, n Apps Sin , 7 4 1 0
%11110111 Stat Prgm Cos ) 8 5 2 .
%11111011 -
Vars Tan ( 9 6 3 (-)
%11111101 - Clear ^ - + Enter
%11111110 - - - - Up Right Left Down

TI-83 Links

WabbitEmu - Fine Ti-83 emulator - you'll need your own rom files from somewhere!
Learn ASM in 28 days - I learned from this tutorial, it's a great guide that covers the Ti-83