Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: Juju on October 02, 2013, 04:53:34 pm
-
This post has originally been posted by SirCmpwn here (http://tiplanet.org/forum/viewtopic.php?f=10&t=13128) and requested it to be crossposted on Omnimaga.
Note: There is a reward of 1 BTC ($111 USD at the time of writing) to the first person to submit a working color KnightOS kernel to [email protected]. If you are unfamiliar with Bitcoin, read up here (http://bitcoin.org/en/).
Hi there! I need some help getting support for the TI-84+ Color Silver Edition in KnightOS. I started working on it a few weeks ago, and here's the current status of the color project:
- You can create KnightOS 8cu files and send them with BrandonW's UOSRECV tool
- Nearly all existing KnightOS features work
- The screen is not initialized correctly
Everything works great, except for the color LCD. I cannot get it to start up correctly. Here's what the color version of KnightOS looks like:
(https://mediacru.sh/F0iXtSovMewF.png)
Note that the kernel works perfectly in KermM's jsTIfied emulator, which has poor emulation for the color LCD.
KnightOS Technical Background
For those of you unaware of how KnightOS is developed, here's some insight. The source code is hosted on and managed on GitHub (https://github.com/KnightSoft), and is written mostly in z80 assembly. There are a number of git repositories:
- kernel (https://github.com/KnightSoft/kernel), which is the core of KnightOS and does nothing on its own
- KnightOS (https://github.com/KnightSoft/KnightOS) is built on the kernel and provides the "KnightOS experience"
- CreateUpgrade (https://github.com/KnightSoft/CreateUpgrade) creates and signs 8xu (and 73u and 8cu) upgrade files
There are more, but these ones are the ones that are important to KnightOS color support.
The relevant code
Color support is being worked on in the `color` git branch. The important code is this, which is meant to initialize the LCD:
; Destroys C
; A: Register
; HL: Value
setLcdRegister:
out (0x10), a \ out (0x10), a
ld c, 0x11
out (c), h
out (c), l
ret
colorLcdOn:
; TODO: Research this more, it's probably not all required and we might want some of it done different.
; Could also probably be optimized if we didn't use this lcdout macro, but I'll save that for when the
; LCD is more well understood and everything is working.
lcdout(0x01, 0x0000) ; Reset Out.Ctrl.1: Ensure scan directions are not reversed
lcdout(0x02, 0x0200) ; LCD Driving Control: Sets inversion mode=line inversion and disables it
lcdout(0x03, 0x1038) ; Init. Entry Mode: Cursor moves up/down, down, left, disable
lcdout(0x08, 0x0202) ; Set front & back porches: 2 blank lines top & bottom
lcdout(0x09, 0x0000) ; Reset Disp.Ctrl.3: Resets scanning stuff and off-screen voltage
lcdout(0x0A, 0x0000) ; Disp.Ctrl.4: No FMARK
lcdout(0x0C, 0x0000) ; RGB Disp.: Off
lcdout(0x0D, 0x0000) ; FMARK position: Off
lcdout(0x60, 0x2700) ; Driver Output Ctrl. 2
lcdout(0x61, 0x0001) ; Base Image Display Ctrl: Use color inversion, no vertical scroll, reset voltage in non-display level
lcdout(0x6A, 0x0000) ; Reset Vertical Scroll Ctrl.
call colorLcdWait
lcdout(0x10, 0x1190) ; Init Pwr.Ctrl.1: Exit standby, fiddle with voltages, enable
lcdout(0x11, 0x0227) ; Pwr.Ctrl.2: Configure voltages
call colorLcdWait
lcdout(0x12, 0x008C) ; Pwr.Ctrl.3: More voltages
call colorLcdWait
lcdout(0x13, 0x1800) ; Pwr.Ctrl.4: Take a wild guess
lcdout(0x29, 0x0030) ; Pwr.Ctrl.7: I'm not an LCD engineer, don't ask me.
lcdout(0x2B, 0x000B) ; Set frame rate to 70
call colorLcdWait
; Don't touch the gamma control ones, no one knows what they mean
lcdout(0x30, 0x0000) ; Gamma Control 1
lcdout(0x31, 0x0305) ; Gamma Control 2
lcdout(0x32, 0x0002) ; Gamma Control 3
lcdout(0x35, 0x0301) ; Gamma Control 4
lcdout(0x36, 0x0004) ; Gamma Control 5
lcdout(0x37, 0x0507) ; Gamma Control 6
lcdout(0x38, 0x0204) ; Gamma Control 7
lcdout(0x39, 0x0707) ; Gamma Control 8
lcdout(0x3C, 0x0103) ; Gamma Control 9
lcdout(0x3D, 0x0004) ; Gamma Control 10
lcdout(0x50, 0x0000) ; Horiz.Win.Start: 0
lcdout(0x51, 0x00EF) ; Horiz.Win.End: 239 = 240-1
lcdout(0x52, 0x0000) ; Vert.Win.Start: 0
lcdout(0x53, 0x013F) ; Vert.Win.End: 319 = 320-1
call colorLcdWait
lcdout(0x07, 0x0133) ; Disp.Ctrl.1: LCD scan & light on, ready to enter standby
; Turn on backlight
in a, (0x3A)
set 5, a
out (0x3A), a
; Values found in TIOS, but not wikiti:
;lcdout(0x07, 0x0000) ; Settings modes, clears it for some reason?
;call colorLcdWait
;lcdout(0x10, 0x07F0) ; More power control
;call colorLcdWait
;lcdout(0x10, 0x07F1) ; Ditto
;call colorLcdWait
lcdout(0x03, 0b1000000010111000) ; Entry mode the way we want it
ret
colorLcdOff:
lcdout(0x07, 0x00)
call colorLcdWait
lcdout(0x10, 0x07F0)
call colorLcdWait
lcdout(0x10, 0x07F1)
; Turn off backlight
in a, (0x3A)
res 5, a
out (0x3A), a
ret
; 40 milliseconds-ish @ 6 MHz
colorLcdWait:
ld b, 0x7F
ld c, 0xFF
ld hl, 0x8000
.loop:
ld a, (hl)
ld (hl), a
dec bc
ld a, c
or b
jp nz, .loop
ret
This code is derived from a combination of reading wikiti (http://wikiti.brandonw.net/index.php?title=84PCSE:LCD_Controller), the LCD datasheet (http://www.displayfuture.com/Display/datasheet/controller/ILI9335.pdf), and TIOS disassemblies. The code can be found in the display-color.asm file of the kernel repository.
How you can help
Want to help out? Here's how you can:
Download (http://ge.tt/api/1/files/14Pmect/0/blob?download) the latest version of the kernel with color support. If you're familiar with git and comfortable in a command line, use "git clone --recursive git://github.com/KnightSoft/KnightOS.git" and navigate to the kernel directory, then run "git checkout color".
Windows
Install cygwin (http://cygwin.com/) and make sure you install GNU Make with it. Open up a cygwin terminal and navigate to where you have saved the kernel's source code. Run "make TI84pCSE" from that directory to create a kernel ROM. You can then create an 8cu upgrade file by running "CreateUpgrade.exe TI84pCSE bin/kernel-TI84pCSE.rom 0F.key kernel.8cu 00".
Linux/Mac
Make sure you have the latest version of tilp. Install mono (Arch: yaourt -S mono, Debian/Ubuntu: apt-get install mono-complete, Fedora: yum install mono). Run make TI84pCSE from the source code's root folder. Build an 8xu upgrade file with "mono CreateUpgrade.exe TI84pCSE bin/kernel-TI84pCSE.rom 0A.key kernel.8xu 00".
Testing
Download BrandonW's UOSRECV (https://gist.github.com/SirCmpwn/www.cemetech.net/forum/viewtopic.php?t=9111) tool and send it to your calculator. Run "Asm(prgmUOSRECV" and wait for it to prompt for an OS. Send the upgrade with TI-Connect or tilp. Note that tilp support for the 84+ CSE is poor, and it may not work correctly. It is suggested that you press reset once more after receving the OS, instead of just jumping straight into it from the boot code's OS receiving code.
After some basic system initialization, the color kernel jumps into a test loop. The LCD backlight should blink 10 times, then the calculator will wait for you to press the ON key. The backlight will blink another 10 times and you'll enter the debug loop. You can press different keys to test out different things:
- A: Backlight ON
- B: Backlight OFF
- C: Initialize the LCD (call colorLcdOn)
- D: Turn off the device
Pressing C should ideally initialize the LCD and set it to a solid RED color.
The code for the debug loop can be found at the bottom of boot.asm. Feel free to modify any part of the kernel to help figure out what's going on.
To re-install TIOS, hold down DEL and press the reset button on the back. You should now be able to send TIOS.
So, want to make a quick bitcoin and help get third party operating systems onto the 84+ CSE? Any questions can be directed at [email protected], and I'll be keeping an eye on the threads in each forum I see this posted in.
EDIT(Eeems): updated download link
EDIT2(Eeems): updated CreateUpgrade.exe call
-
Pretty cool. I hope someone can pull it off. Not me though because I don't have a CSE. :/
-
BrandonW's tool link is not working!
-
night os for the cse....nice :)
-
Message from SirCmpwn : the correct link for the color kernel is this one : http://ge.tt/api/1/files/14Pmect/0/blob?download
-
A CSE version would definitively be nice. However, since it would be hard to compete against the mainstream TI-OS, he would definitvely need to make KOS as fast as possible to display stuff and it might need to be released with some add-ons such as a fast graphing app and fast home screen maths.
-
Was there ever a finished version for the regular 84+?
-
Hi there! I need some help getting support for the TI-84+ Color Silver Edition in KnightOS. I started working on it a few weeks ago, and here's the current status of the color project:
- The screen is not initialized correctly
Everything works great, except for the color LCD. I cannot get it to start up correctly.
Just use the MicrOS screen init code (http://www.ticalc.org/archives/files/fileinfo/453/45396.html), from the files lcd.asm and lcd_data.asm. It basically just does the same port writes as the boot code does, but using a script. You can strip out half the script features for a smaller init routine.
Oh, by the way, there might still be a minor bug in the GPIO initialization (port 39h). It should be initialized to E0h, not F0h.
Also, WARNING WARNING DANGER DANGER: The calculator does not seem to have a hardware low-battery shut-off. Your software must check the battery regularly and power-off if the battery is bad. I've been doing some research on this. I have some code for testing the battery level, but I haven't figured out exactly how to check the external power and charging status. Bit 4 of 3A seems to indicate if the battery is actively charging, but if you're plugged in and drawing power from USB without charging, it won't show that. I've also actually seen some behavior that suggests the battery will not charge is the USB controller is in the wrong state.
-
Hi there! So there has been some progress. A new kernel can be downloaded from here (http://ge.tt/api/1/files/10VcYet/0/blob?download). I have switched to the MicrOS LCD initialization code. Unfortunately, this does not seem to help. Does anyone know if DrDnar has successfully run MicrOS as an operating system, instead of an app? The LCD has already been initialized by TIOS by the time an app gets run.
The current behavior is to start up properly (and you can control the backlight), but attempting to initialize the color screen and clear it to solid grey does not work. There is no visible change in the LCD.
source (http://tiplanet.org/forum/viewtopic.php?f=10&t=13128&p=149273#p149273)
-
Was there ever a finished version for the regular 84+?
Not even close. IIRC the main stuff was done, but on the user's end, the OS did nothing at all other than maybe turning ON then shutting down.
-
Hi there! So there has been some progress. A new kernel can be downloaded from here (http://ge.tt/api/1/files/10VcYet/0/blob?download). I have switched to the MicrOS LCD initialization code. Unfortunately, this does not seem to help. Does anyone know if DrDnar has successfully run MicrOS as an operating system, instead of an app? The LCD has already been initialized by TIOS by the time an app gets run.
The current behavior is to start up properly (and you can control the backlight), but attempting to initialize the color screen and clear it to solid grey does not work. There is no visible change in the LCD.
The MicrOS LCD init code uses the crystals and HALT for timing if I remember correctly; check to make sure you're duplicating the delays properly, because the datasheet on the driver clearly specifies them as necessary. At any rate, it has been tested, because turning the calculator off and on works. You have to completely uninitialize the LCD when you turn off the calculator or else the driver continues to consume current. Not as much as the backlight for sure, but still a lot more than the B&W LCD would consume because it's a very different type of LCD.
-
SirCmpwn, pm me or send me an email at [email protected]. I have an untested routine for the initialization.
-
I based it around the datasheet rather than the os. Here's what's happening:
LCD Power Supply ON sequence:
Initial:
{07:4L}DTE=0 (VGH gate output)
{07:01L}D[1:0]=00 (Halt display panel off)
{07:5L}GON=0 (VGH gate output)
//{12:4L?}PON=0 (VGL output) Not documented in the ILI9335 datasheet, WikiTI and the ILI9325 datasheet point to this, I suspect its $06:0L?
set:
{11:012L}VC[2:0]=111 (voltage ratio)
{12:0123L}VRH[3:0]=1100 (amplify rate)
{12:7L}VCIRE=1 (sel ext or int)
{29:012345L}VCM[5:0]=110000 (voltage)
{13:01234H}VDV[5:0]=11000 (amplitude ratio)
//{12:4L?}PON=0 (VGL output)
{10:012H}BT[2:0]=000 (step up voltage)
wait >= 50ms
Set:
{10:012H}BT[2:0]=001 (step up voltage)
//{12:4L?}PON=1 (VGL output)
{10:456L}AP[2:0]=001 (op amp current)
{10:7L}APE=1 (power supply enable)
{11:012H}DC1[2:0]=010 (step up frequency)
{11:456L}DC0[2:0]=010 (step up frequency)
wait >= 80ms
set display registers
set:
{10:4H}SAP=1 (source driver)
{07:01L}D[1:0]=01 (Operate internal)
wait 2 or more frames
{07:5L}GON=1 (VGL gate output)
{07:01L}D[1:0]=11 (Operate normal)
wait 2 or more frames
{07:4L}DTE=1 (Normal gate output)
*Edit:
I've attached the kernel, I will tweak the values a bit, clean it up a little, and send you a copy.
-
POST BY SIRCMPWN ON TI-PLANET :
(https://mediacru.sh/sIsfPzVIE5UK.jpe)
I have got the LCD to start up correctly, and I have got legacy LCD emulation working correctly. Thanks to AssemblyBandit and Runer112 for helping make it happen. If either of you would like a reward, I'll offer 1 BTC each. Send your bitcoin address to [email protected], and thanks for all the help!
Expect to hear news of complete TI-84+ CSE support for KnightOS in the coming days. It's not ready yet - but it's close.
-
that's pretty awesome! :D
-
Yeah o/
-
:w00t:
First, I apologize for leaving the code in such a mess, it was about 2am when I posted everything and I was ready for bed! It takes *forever* to make a change then test it and I had planned to continue working on it. I hadn't reviewed the TIOS, I just wrote a routine based on the datasheet and kinda merged it with the original code after verifying the values. Note that the datasheet isn't perfect and there is nothing more frustrating than a datasheet with missing info and errors! At first TI Connect (and my computer) didn't make it any easier by not recognizing my calc moments before I would upload KnightOS, then USOREC would throw an error, then the RAM gets cleared and I would have to start over! Some notes for anyone trying to test it: Cygwin needs 'make' under the dev tree, Tilp cannot be used, be ready for windows to try to reinstall your calc while using USOREC, use 'cd c:/cygwin/whatever' to navigate (not sure if spaces are allowed), and the createupgrade line was not working for me in the terminal, just put the line 'CreateUpgrade.exe TI84pCSE bin/kernel-TI84pCSE.rom 0F.key kernel.8cu 00' into a batch file. I was so ready to give up before I even tested it! I'm glad it all worked out though, and the work on KnightOS is very admirable (and USOREC!). I really wanted the bitcoin, not for monetary use, but more like a prize. However, due to its monetary value, I think it would be better as a prize for the 2013 Omnimaga Contest if its appropriate/practical.
-
To clarify exactly what was done, here's the original routine along with the changes I made:
The original routine unaltered, copied straight from display-color.asm:
colorLcdOn:
; TODO: Research this more, it's probably not all required and we might want some of it done different.
; Could also probably be optimized if we didn't use this lcdout macro, but I'll save that for when the
; LCD is more well understood and everything is working.
lcdout(0x01, 0x0000) ; Reset Out.Ctrl.1: Ensure scan directions are not reversed
lcdout(0x02, 0x0200) ; LCD Driving Control: Sets inversion mode=line inversion and disables it
lcdout(0x03, 0x1038) ; Init. Entry Mode: Cursor moves up/down, down, left, disable
lcdout(0x08, 0x0202) ; Set front & back porches: 2 blank lines top & bottom
lcdout(0x09, 0x0000) ; Reset Disp.Ctrl.3: Resets scanning stuff and off-screen voltage
lcdout(0x0A, 0x0000) ; Disp.Ctrl.4: No FMARK
lcdout(0x0C, 0x0000) ; RGB Disp.: Off
lcdout(0x0D, 0x0000) ; FMARK position: Off
lcdout(0x60, 0x2700) ; Driver Output Ctrl. 2
lcdout(0x61, 0x0001) ; Base Image Display Ctrl: Use color inversion, no vertical scroll, reset voltage in non-display level
lcdout(0x6A, 0x0000) ; Reset Vertical Scroll Ctrl.
call colorLcdWait
lcdout(0x10, 0x1190) ; Init Pwr.Ctrl.1: Exit standby, fiddle with voltages, enable
lcdout(0x11, 0x0227) ; Pwr.Ctrl.2: Configure voltages
call colorLcdWait
lcdout(0x12, 0x008C) ; Pwr.Ctrl.3: More voltages
call colorLcdWait
lcdout(0x13, 0x1800) ; Pwr.Ctrl.4: Take a wild guess
lcdout(0x29, 0x0030) ; Pwr.Ctrl.7: I'm not an LCD engineer, don't ask me.
lcdout(0x2B, 0x000B) ; Set frame rate to 70
call colorLcdWait
; Don't touch the gamma control ones, no one knows what they mean
lcdout(0x30, 0x0000) ; Gamma Control 1
lcdout(0x31, 0x0305) ; Gamma Control 2
lcdout(0x32, 0x0002) ; Gamma Control 3
lcdout(0x35, 0x0301) ; Gamma Control 4
lcdout(0x36, 0x0004) ; Gamma Control 5
lcdout(0x37, 0x0507) ; Gamma Control 6
lcdout(0x38, 0x0204) ; Gamma Control 7
lcdout(0x39, 0x0707) ; Gamma Control 8
lcdout(0x3C, 0x0103) ; Gamma Control 9
lcdout(0x3D, 0x0004) ; Gamma Control 10
lcdout(0x50, 0x0000) ; Horiz.Win.Start: 0
lcdout(0x51, 0x00EF) ; Horiz.Win.End: 239 = 240-1
lcdout(0x52, 0x0000) ; Vert.Win.Start: 0
lcdout(0x53, 0x013F) ; Vert.Win.End: 319 = 320-1
call colorLcdWait
lcdout(0x07, 0x0133) ; Disp.Ctrl.1: LCD scan & light on, ready to enter standby
; Turn on backlight
in a, (0x3A)
set 5, a
out (0x3A), a
; Values found in TIOS, but not wikiti:
;lcdout(0x07, 0x0000) ; Settings modes, clears it for some reason?
;call colorLcdWait
;lcdout(0x10, 0x07F0) ; More power control
;call colorLcdWait
;lcdout(0x10, 0x07F1) ; Ditto
;call colorLcdWait
lcdout(0x03, 0b1000000010111000) ; Entry mode the way we want it
ret
After my modifications:
colorLcdOn:
; TODO: Research this more, it's probably not all required and we might want some of it done different.
; Could also probably be optimized if we didn't use this lcdout macro, but I'll save that for when the
; LCD is more well understood and everything is working.
lcdout(0x07, 0x0000) ; Reset Disp.Ctrl.1: LCD scanning, command processing OFF
lcdout(0x06, 0x0000)
; lcdout(0x10, 0x07F1) ; Reset Pwr.Ctrl.1: Start RC oscillator, set voltages
lcdout(0x11, 0x0007) ; Pwr.Ctrl.2: Configure voltages
lcdout(0x12, 0x008C) ; Pwr.Ctrl.3: More voltages
lcdout(0x13, 0x1800) ; Pwr.Ctrl.4: Take a wild guess
lcdout(0x29, 0x0030) ; Pwr.Ctrl.7: I'm not an LCD engineer, don't ask me.
call colorLcdWait
lcdout(0x10, 0x0190) ; Init Pwr.Ctrl.1: Exit standby, fiddle with voltages, enable
lcdout(0x11, 0x0227) ; Pwr.Ctrl.2: Configure voltages
lcdout(0x06, 0x0001)
call colorLcdWait
call colorLcdWait
lcdout(0x01, 0x0000) ; Reset Out.Ctrl.1: Ensure scan directions are not reversed
lcdout(0x02, 0x0200) ; LCD Driving Control: Sets inversion mode=line inversion and disables it
lcdout(0x03, 0x10b8) ; Init. Entry Mode: Cursor moves up/down, down, left, disable
lcdout(0x08, 0x0202) ; Set front & back porches: 2 blank lines top & bottom
lcdout(0x09, 0x0000) ; Reset Disp.Ctrl.3: Resets scanning stuff and off-screen voltage
lcdout(0x0A, 0x0000) ; Disp.Ctrl.4: No FMARK
lcdout(0x0C, 0x0000) ; RGB Disp.: Off
lcdout(0x0D, 0x0000) ; FMARK position: Off
lcdout(0x60, 0x2700) ; Driver Output Ctrl. 2
lcdout(0x61, 0x0001) ; Base Image Display Ctrl: Use color inversion, no vertical scroll, reset voltage in non-display level
lcdout(0x6A, 0x0000) ; Reset Vertical Scroll Ctrl.
lcdout(0x90, 0x0010)
lcdout(0x92, 0x0600)
lcdout(0x95, 0x0200)
lcdout(0x97, 0x0c00)
lcdout(0x30, 0x0000) ; Gamma Control 1
lcdout(0x31, 0x0305) ; Gamma Control 2
lcdout(0x32, 0x0002) ; Gamma Control 3
lcdout(0x35, 0x0301) ; Gamma Control 4
lcdout(0x36, 0x0004) ; Gamma Control 5
lcdout(0x37, 0x0507) ; Gamma Control 6
lcdout(0x38, 0x0204) ; Gamma Control 7
lcdout(0x39, 0x0707) ; Gamma Control 8
lcdout(0x3C, 0x0103) ; Gamma Control 9
lcdout(0x3D, 0x0004) ; Gamma Control 10
lcdout(0x50, 0x0000) ; Horiz.Win.Start: 0
lcdout(0x51, 0x00EF) ; Horiz.Win.End: 239 = 240-1
lcdout(0x52, 0x0000) ; Vert.Win.Start: 0
lcdout(0x53, 0x013F) ; Vert.Win.End: 319 = 320-1
lcdout(0x2B, 0x000B) ; Set frame rate to 70
lcdout(0x10, 0x1190) ; Init Pwr.Ctrl.1: Exit standby, fiddle with voltages, enable
lcdout(0x07, 0x0001) ; Reset Disp.Ctrl.1: LCD scanning, command processing OFF
call colorLcdWait
call colorLcdWait
lcdout(0x07, 0x0023) ; Reset Disp.Ctrl.1: LCD scanning, command processing OFF
call colorLcdWait
call colorLcdWait
lcdout(0x07, 0x0133) ; Disp.Ctrl.1: LCD scan & light on, ready to enter standby
; Turn on backlight
; Values found in TIOS, but not wikiti:
;lcdout(0x07, 0x0000) ; Settings modes, clears it for some reason?
;call colorLcdWait
;lcdout(0x10, 0x07F0) ; More power control
;call colorLcdWait
;lcdout(0x10, 0x07F1) ; Ditto
;call colorLcdWait
;lcdout(0x03, 0b1000000010111000) ; Entry mode the way we want it
ret
As you can see, I added the Panel Interface Registers, Register 6 (which is not documented anywhere but by me!), and sent the proper values (in order) according to what I've gathered off the datasheet. As requested, and as verified by the video I posted, it initializes the display and I included the basic overview of what's going on in a previous post.
-
Yeah IIRC he requested help to fix the code compatibility with the 84+CSE. If the original code and description contained any credits and you left them intact, then I don't see anything wrong.