WEBVTT
Kind: captions
Language: en-US

00:00:00.049 --> 00:00:01.920
Hello everyone, thanks for tuning in.

00:00:01.920 --> 00:00:07.020
If you’ve played Game Boy Advance non-SP
version before, you would probably remember

00:00:07.020 --> 00:00:08.969
its non-backlit screen design.

00:00:08.969 --> 00:00:13.170
It’s critical to find the right angle to
watch the screen while playing it.

00:00:13.170 --> 00:00:18.590
The design also makes it impossible to play
in the dark, unless you have a flashlight.

00:00:18.590 --> 00:00:23.930
As a result, in recent years, there have been
a lot of backlight mods introduced, to improve

00:00:23.930 --> 00:00:26.416
the image quality and overall useability.

00:00:26.888 --> 00:00:32.189
However, instead of upgrading it, would it
be possible to downgrade it?

00:00:32.189 --> 00:00:37.613
Like downgrade to the monochrome non-backlight
LCD like those on the original DMG GameBoy

00:00:37.940 --> 00:00:41.360
In today’s episode, I am going to try such
a mod.

00:00:41.360 --> 00:00:45.660
The first task is to find screens with matching
sizes and resolutions.

00:00:45.660 --> 00:00:48.660
Surprisingly such screens do exist.

00:00:48.660 --> 00:00:53.539
With some modifications done to the case,
the screen fits into the case nicely.

00:00:53.539 --> 00:00:55.230
Next onto building the circuit.

00:00:55.230 --> 00:00:58.540
Apparently, these screens use different protocols.

00:00:58.540 --> 00:01:01.090
So directly hooking up the signal won’t
work.

00:01:01.090 --> 00:01:04.210
I will need some chips to convert between
them.

00:01:04.210 --> 00:01:08.060
Normally, a low-power FPGA would be the best
choice here.

00:01:08.060 --> 00:01:13.280
However, when I was building this project
earlier this year, all variants of ICE40,

00:01:13.280 --> 00:01:17.939
MAX10, or SPARTAN 6 7 FPGAs are out of stock.

00:01:17.939 --> 00:01:22.180
As a result, I decided to give RP2040 another
go.

00:01:22.180 --> 00:01:28.550
With that being said, the plan is to use PIO
to capture the LCD output of GBA, then combine

00:01:28.550 --> 00:01:34.880
with what I had previously, a software sigma-delta
modulation grayscale scheme, to convert the

00:01:34.880 --> 00:01:40.000
color display output from GBA to a grayscale
LCD input.

00:01:40.000 --> 00:01:41.970
Let’s look at the schematics.

00:01:41.970 --> 00:01:43.810
It should be quite straightforward.

00:01:43.810 --> 00:01:48.560
The Game Boy Advances’ LCD input connector
contains the power supply to power the whole

00:01:48.560 --> 00:01:53.600
board and the video signal that goes directly
into RP2040.

00:01:53.600 --> 00:01:58.759
On the other end, the RP2040’s video output
goes directly into the mono LCD.

00:01:58.759 --> 00:02:04.049
The LCD I am using here doesn’t have an
integrated power supply, so I am using a step-up

00:02:04.049 --> 00:02:08.590
DCDC converter here to generate the required
LCD driving supply.

00:02:08.590 --> 00:02:13.349
You probably remember from GameBoy or similar
devices that these screens typically need

00:02:13.349 --> 00:02:15.220
a dedicated contrast knob.

00:02:15.220 --> 00:02:17.000
That’s essentially adjusting this voltage.

00:02:17.000 --> 00:02:22.430
I don’t want to mod the case to add an additional
knob, so I added 4 solder pads to allow connecting

00:02:22.430 --> 00:02:28.150
GBA’s buttons to the microcontroller, and
let the microcontroller generate a PWM signal,

00:02:28.150 --> 00:02:33.600
getting RC filtered to a DC value, then feed
into the DCDC converter as part of the feedback

00:02:33.600 --> 00:02:36.280
voltage.

00:02:36.280 --> 00:02:39.540
The LCD also needs several bias voltages.

00:02:39.540 --> 00:02:43.659
Improper bias voltage could lead to poor contrast
and increased cross-talk.

00:02:43.659 --> 00:02:48.200
I am using a resistor voltage divider to generate
the required voltages.

00:02:48.200 --> 00:02:53.019
Then a basic LM324 opamp to buffer the voltage.

00:02:53.019 --> 00:02:54.959
This is about the main components.

00:02:54.959 --> 00:03:02.010
Import that into the KiCAD PCB editor, place,
route, run the DRC, and we are ready to send

00:03:02.010 --> 00:03:03.713
that to the PCB manufacturer.

00:03:04.059 --> 00:03:05.336
Then comes the soldering.

00:03:05.475 --> 00:03:10.159
Soldering everything and I am ready to test
it.

00:03:10.159 --> 00:03:14.299
The first is to write a simple program to
just enable the screen power supply and check

00:03:14.299 --> 00:03:19.400
if DCDC works and if I can control the voltage
over PWM.

00:03:19.400 --> 00:03:20.400
This looks good.

00:03:20.400 --> 00:03:24.670
Then I can write a program to drive the screen
with some static images to test the video

00:03:24.670 --> 00:03:25.670
output path.

00:03:25.670 --> 00:03:28.430
I am reusing the code from my previous video.

00:03:28.430 --> 00:03:29.909
This also looks good.

00:03:29.909 --> 00:03:33.690
The next task is to capture the video input
from GBA.

00:03:33.690 --> 00:03:38.650
The PIO code is quite simple: wait for the
rising edge of vertical sync, then wait for

00:03:38.650 --> 00:03:42.689
the rising edge of the pixel clock, and sample
the input.

00:03:42.689 --> 00:03:48.120
I wired my hardware wrong, so I have to do
another bit reversal to correct the MSB and

00:03:48.120 --> 00:03:53.070
LSB, but normally one would just use the IN
instruction to capture from PINS.

00:03:53.070 --> 00:03:57.330
What if I pipe the incoming data directly
to the frame buffer?

00:03:57.330 --> 00:04:00.110
I am already seeing the image, this is good
news!

00:04:00.110 --> 00:04:04.957
GBA gates clock signal during blanking, so
I don’t really need to worry about that much

00:04:04.997 --> 00:04:08.480
If I can correct the color mapping, then I
am good to go.

00:04:08.480 --> 00:04:11.890
Color mapping is, however, a slow process.

00:04:11.890 --> 00:04:15.220
Here is a common RGB to luminance formula.

00:04:15.220 --> 00:04:21.340
What I need is an integer approximation, that
would convert my 0 to 15 R/G/B input value

00:04:21.340 --> 00:04:24.590
to 0 to 63 luminance value.

00:04:24.590 --> 00:04:26.310
This is what I ended up with.

00:04:26.310 --> 00:04:31.090
However, this is still too slow to calculate
at video rate, mainly due to the division

00:04:31.090 --> 00:04:32.090
operation.

00:04:32.090 --> 00:04:34.600
I had to convert this into a look-up table.

00:04:34.600 --> 00:04:41.210
Though now if this is pre-calculated, it’s
not that important I only use integer operations.

00:04:41.210 --> 00:04:44.520
The only missing feature now is adjusting
the contrast.

00:04:44.520 --> 00:04:49.470
I had several solder points for connecting
to GBA’s keypad test point.

00:04:49.470 --> 00:04:53.740
Once they are connected, simply add code to
read the button values and adjust the PWM

00:04:53.740 --> 00:04:54.740
duty cycle.

00:04:54.740 --> 00:04:56.863
So this is now finished! Let's take a look

00:05:20.000 --> 00:05:23.720
This is about the end of the video, hope you
liked it, and thanks for watching.

