Author Topic: TI-84+ CSE support for KnightOS  (Read 10726 times)

0 Members and 1 Guest are viewing this topic.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
TI-84+ CSE support for KnightOS
« on: October 02, 2013, 04:53:34 pm »
This post has originally been posted by SirCmpwn here 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.

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:



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, and is written mostly in z80 assembly. There are a number of git repositories:

  • kernel, which is the core of KnightOS and does nothing on its own
  • KnightOS is built on the kernel and provides the "KnightOS experience"
  • 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:

Code: [Select]
; 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, the LCD datasheet, 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 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 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 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
« Last Edit: October 02, 2013, 06:49:44 pm by Eeems »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI-84+ CSE support for KnightOS
« Reply #1 on: October 02, 2013, 05:18:28 pm »
Pretty cool. I hope someone can pull it off. Not me though because I don't have a CSE. :/

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI-84+ CSE support for KnightOS
« Reply #2 on: October 02, 2013, 05:31:41 pm »
BrandonW's tool link is not working!

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: TI-84+ CSE support for KnightOS
« Reply #3 on: October 02, 2013, 05:41:43 pm »
night os for the cse....nice :)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: TI-84+ CSE support for KnightOS
« Reply #4 on: October 02, 2013, 06:18:16 pm »
Message from SirCmpwn : the correct link for the color kernel is this one : http://ge.tt/api/1/files/14Pmect/0/blob?download

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TI-84+ CSE support for KnightOS
« Reply #5 on: October 02, 2013, 08:07:15 pm »
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.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: TI-84+ CSE support for KnightOS
« Reply #6 on: October 02, 2013, 08:29:12 pm »
Was there ever a finished version for the regular 84+?
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: TI-84+ CSE support for KnightOS
« Reply #7 on: October 02, 2013, 09:08:26 pm »
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, 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.
« Last Edit: October 02, 2013, 09:20:56 pm by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline persalteas

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 231
  • Rating: +44/-4
  • z80 poweeer
    • View Profile
    • Tout-82
Re: TI-84+ CSE support for KnightOS
« Reply #8 on: October 03, 2013, 12:22:05 pm »
Quote from: SirCmpwn
Hi there! So there has been some progress. A new kernel can be downloaded from here. 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
« Last Edit: October 03, 2013, 12:23:09 pm by persalteas »


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: TI-84+ CSE support for KnightOS
« Reply #9 on: October 03, 2013, 07:49:33 pm »
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.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: TI-84+ CSE support for KnightOS
« Reply #10 on: October 03, 2013, 10:51:34 pm »
Quote from: SirCmpwn
Hi there! So there has been some progress. A new kernel can be downloaded from here. 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.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI-84+ CSE support for KnightOS
« Reply #11 on: October 04, 2013, 02:19:39 am »
SirCmpwn, pm me or send me an email at [email protected]. I have an untested routine for the initialization.
« Last Edit: October 04, 2013, 02:21:12 am by AssemblyBandit »

Offline AssemblyBandit

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 374
  • Rating: +60/-1
  • ~AssemblyBandit~
    • View Profile
    • briandm82.com
Re: TI-84+ CSE support for KnightOS
« Reply #12 on: October 05, 2013, 02:10:38 am »


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.
« Last Edit: October 05, 2013, 02:22:06 am by AssemblyBandit »

Offline nikitouzz

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 215
  • Rating: +22/-1
    • View Profile
Re: TI-84+ CSE support for KnightOS
« Reply #13 on: October 05, 2013, 07:11:42 am »
POST BY SIRCMPWN ON TI-PLANET :



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.
mes records personels :

2x2x2 : 2.18 secondes / 2x2x2 une main : 21.15 secondes / 2x2x2 yeux bandés : 47.59
3x3x3 : 5.97 secondes / 3x3x3 une main : 49.86 secondes
4x4x4 : 1.49 minutes / 4x4x4 une main : 6.50 minutes
5x5x5 : 4.10 minutes / 5x5x5 une main : 18.02 minutes
6x6x6 : 8.10 minutes
7x7x7 : 16.03 minutes
9x9x9 : 58.26 minutes

megaminx : 5.59 minutes / pyraminx : 7.91 secondes / square-one : 1.07 minutes

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: TI-84+ CSE support for KnightOS
« Reply #14 on: October 05, 2013, 07:19:42 am »
that's pretty awesome! :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!