Jump to content

- - - - -

Getting Grayscale Pixels On Sh4

sh4 grayscale monochrome lcd casio fx-9860g fx-9750gii graph85

  • Please log in to reply
4 replies to this topic

#1 Viliami


    Casio Addict

  • Moderator
  • PipPipPip
  • 99 posts
  • Gender:Male
  • Location:New Zealand
  • Interests:C++ - OpenGL,SDL
    Python - Pygame
    Java - SFML
    C - Casio SDK

  • Calculators:
    FX-9750 GII upgraded to FX-9860 GII

Posted 29 November 2015 - 08:17 AM

Does anybody know how to get gray-scale pixels on SH4-type fx-9860gii model calculators.

I've read that Kucalc got it working back in 2007 but that only for sh3. I know C and C++ but I don't know how to write assembly.


The Casio fx-9860 model series only has a monochrome LCD, therefore it can only display pixels in black and white, but a lot of people found ways to emulate tones of gray(gray-scale) on the LCDs.

You have to switch the pixels on and off at a high frequency to trick our eyes to see gray. A darker gray can be achieved by displaying the black pixels for a little while longer.

I've already tried doing this in C, but the flicker speed is not even close to the speed needed to achieve a gray looking pixel.


I know it's possible because people have already done it for the 9860G, and they also achieved gray-scale on the TI-83+ using the same technique.

I've seen it used in Doodle Jump and Mario Land CE and it looks awesome. Games look so much better with gray-scale.


Please reply if you have any information/comments about gray-scale on the SH4-type CPUs.

Edited by Viliami, 01 December 2015 - 12:38 AM.

  • frankmar98 and imyxh like this

#2 imyxh



  • Members
  • Pip
  • 1 posts
  • Gender:Male
  • Location:Washington, USA
  • Interests:reverse engineering

  • Calculators:
    fx-9860GII-2 (SH-4A)

Posted 19 August 2019 - 10:35 PM

Hello! I see it's been a while since this was posted. I took a look into PierrotLL's simplified version of kucalc's work and it looks like grayscale was implemented with a whole new Screen struct, holding a light buffer and a dark buffer on the heap as well as timing variables.


The interesting part was, I couldn't find any part of that code that seemed to switch between the buffers or any sort of loop like that. I suspect that there may have been some interfacing with underlying firmware or something of the sort to do this automatically?


I'm especially suspicious of this because of the following SuperH assembler code:

        mov.l   #h'A0000000, r0
        jmp     @r0

It appears that to turn off the grayscale mode PierrotLL's library jumps to the address 0xA0000000. Part of me wants to guess that that's an fxlib function address, perhaps Bdisp_AreaClr?

I'll be honest, despite being decent at x86 assembler, I can't read C code for shit. So I right now I'm caught up on this sort of thing:

#define INTC (*(volatile struct st_intc *)0xFFFFFEE0)
#define INTX (*(volatile struct st_intx *)0xA4000000)
#define TMU  (*(volatile struct st_tmu  *)0xFFFFFE92)
#define TMU0 (*(volatile struct st_tmu0 *)0xFFFFFE94)

If anyone knows what these expressions do, input would be appreciated.


TL;DR: I think the SH3 grayscale flickering was implemented in some weird low-level way, and perhaps, Viliami, you were trying to do it through the SDK which wouldn't let you flicker as quickly?

#3 TBit



  • Members
  • Pip
  • 26 posts
  • Gender:Male
  • Location:Germany
  • Interests:C/C++, Assembly, Demoscene

  • Calculators:
    FX-9860 GII
    FX-9750 GII
    ClassPad 330 PLUS

Posted 14 January 2020 - 09:54 AM

Hey, I think I can help with this.


These macros define the address to which the corresponding structure (defined above in the code) is mapped. So by writing to the

address, it is possible to access registers of some IO-devices. These include the serial interface, the DMA controller and the TMU (Timer unit).


The way the library switches buffers is by using an interrupt generated by the TMU at a set frequency. I don't know where this interrupt

routine is in the library, but look for:

#pragma interrupt(function)

You can find the documentation here.

Edited by metalvoidzz, 14 January 2020 - 10:01 AM.

#4 KBD2



  • Members
  • Pip
  • 1 posts
  • Gender:Male
  • Location:New Zealand
  • Interests:C/C++

  • Calculators:
    FX-9750GII (Modded)

Posted 30 June 2020 - 08:43 AM

Hi. Sorry if I'm necroing this, but I just got grayscale working for my upgraded SH4 9750GII.


Instead of Casio's SDK, I used fxSDK to manage and build the addin, and gint's runtime to handle the grayscale images. Both as well as the compiler/toolchain have to be built on Linux, but I managed to get everything working using an Ubuntu distribution on Windows using WSL. fx doesn't support C++ unfortunately, but IMO that's outweighed by all the benefits over Casio's SDK.


Here's a topic on Planet Casio with all the relevant info and links (albeit in French, so if you don't speak it have a translator or google chrome handy): http://planet-casio....on-de-gint.html


The tutorial for actually utilising gint's functionalities to make addins is lacking, but the comments in the headers were more than enough for me to get the gist, and I'll be happy to help with my (currently limited) knowledge of the grayscale part.


Hope this helps someone.

Edited by KBD2, 30 June 2020 - 10:15 AM.

#5 CalcLoverHK


    Casio Freak

  • Members
  • PipPipPipPip
  • 257 posts
  • Gender:Male
  • Location:Hong Kong
  • Interests:FPS games, C.Basic

  • Calculators:
    fx-50FHII (2019/1/30)
    fx-991ESPLUS-2 (2023/12/22)
    fx-3650PII (2022/1/15)
    fx-9750GIII (2020/6/13)
    fx-9860G Slim (2024/2/27)
    fx-9860GIISD (2023/3/27)
    fx-9860GIISD-2 (2024/2/5)
    fx-CG20CN (2023/2/12)
    fx-CG50 (2023/10/23)

Posted 30 June 2020 - 09:14 AM

Ah, I remember there are four types of grayscales in gint. Wonder if C.Basic can implement this feature in the future?

Also tagged with one or more of these keywords: sh4, grayscale, monochrome, lcd, casio, fx-9860g, fx-9750gii, graph85

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users