Skip to content

Commit

Permalink
Fixed touch control. Reduced display flicker.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorstenBr committed Nov 5, 2024
1 parent 86298bc commit a042966
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ teaching the topic of computers, programming and electronics from the very botto
Unlike the rest of the series, as far as known, the manual was not translated, and this kit was only sold in German.
<br>
<br>
The kit was produced and distributed by the [Georg Adam Mangold GmbH (GAMA)](https://en.wikipedia.org/wiki/Gama_Toys),
The kit was produced and distributed by [GAMA (Georg Adam Mangold)](https://en.wikipedia.org/wiki/Gama_Toys),
a German toy manufacturer, which had taken over the electronics kit business from Philips in the early 1980s.
Initially still selling under the "Philips" brand, as of 1985 GAMA switched the entire kit series to use their
own "Schuco" brand instead.
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1>Philips MicroComputerLab MC6400<br>Emulator/Virtual Hardware</h1>
Unlike the rest of the series, as far as known, the manual was not translated, and this kit was only sold in German.
<br>
<br>
The kit was produced and distributed by the <a href="https://en.wikipedia.org/wiki/Gama_Toys">Georg Adam Mangold GmbH (GAMA)</a>,
The kit was produced and distributed by <a href="https://en.wikipedia.org/wiki/Gama_Toys">GAMA (Georg Adam Mangold)</a>,
a German toy manufacturer, which had taken over the electronics kit business from Philips in the early 1980s.
Initially still selling under the "Philips" brand, as of 1985 GAMA switched the entire kit series to use their
own "Schuco" brand instead.
Expand Down
24 changes: 13 additions & 11 deletions info/mc6400eprom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -569,20 +569,22 @@
0375: 10 CALL 0 ; CALL ANZ_EIN
0376: 74 F7 BRA $036F ; RETURNS HERE: FUNCTION KEY PRESSED
0378: 7C 2C BNZ $03A6 ; RETURNS HERE: ALPHANUM KEY PRESSED
037A: 84 E5 09 LD EA,=09E5 ; 7SEGMENT DATA: " SPIELE"
037D: 8D D8 ST EA,$FFD8
037F: 84 F6 09 LD EA,=09F6 ; 7SEGMENT DATA: " SPIELE"
0382: BD D8 SUB EA,$FFD8
0384: 64 02 BP $0388
0386: 74 F2 BRA $037A
0388: 85 D8 LD EA,$FFD8
038A: B4 01 00 ADD EA,=0001
038D: 8D D8 ST EA,$FFD8
038F: 4E XCH EA,P2

; PROGRAM 0: MARQUEE
037A: 84 E5 09 LD EA,=09E5 ; LOAD START POINTER (TO " SPIELE ..")
037D: 8D D8 ST EA,$FFD8 ; STORE START POINTER
037F: 84 F6 09 LD EA,=09F6 ; LOAD POINTER TO END OF STRING
0382: BD D8 SUB EA,$FFD8 ; COMPARE POINTER
0384: 64 02 BP $0388 ; BRANCH, WHEN NOT BEHIND THE END YET
0386: 74 F2 BRA $037A ; OTHERWISE RESTART, RESET POINTER TO BEGINNING
0388: 85 D8 LD EA,$FFD8 ; LOAD POINTER
038A: B4 01 00 ADD EA,=0001 ; INCREASE
038D: 8D D8 ST EA,$FFD8 ; UPDATE POINTER
038F: 4E XCH EA,P2 ; MOVE TO P2
0390: 20 2E 09 JSR $092F ; WRITE DISPLAY BUFFER
0393: C4 40 LD A,=40 ; SET TIMEOUT FOR DISPLAY
0395: 11 CALL 1 ; CALL ANZEIGE/DISPLAY
0396: 74 E7 BRA $037F
0396: 74 E7 BRA $037F ; REPEAT

0398: 26 D5 09 LD P2,=09D5 ; 7SEGMENT DATA: "Error"
039B: 20 2E 09 JSR $092F ; WRITE DISPLAY BUFFER
Expand Down
51 changes: 35 additions & 16 deletions js/7segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,54 @@ var led_selected = false;
var led_array = [];
var segment_array = [];
var segment_state = [255,255,255,255,255,255,255,255];
var segment_timeout = [0,0,0,0,0,0,0,0];

function clear_digits()
function clear_digits(num)
{
if (num == 3)
{
var Segments = segment_array[num];
for (var s=0;s<8;s++)
{
Segments[s].style.visibility = "hidden";
led_array[s].checked = false;
}
segment_state[num] = 0;
return;
}
for (var d=0;d<8;d++)
{
if (segment_state[d] != 0)
if (segment_timeout[d] > 0)
{
var Segments = segment_array[d];
for (var s=0;s<8;s++)
{
if (segment_state[d] & (1<<s))
Segments[s].style.visibility = "hidden";
}
segment_state[d] = 0;
segment_timeout[d] -= 1;
}
for (var led=0;led<8;led++)
else
{
led_array[led].checked = false;
if (segment_state[d] != 0)
{
var Segments = segment_array[d];
for (var s=0;s<8;s++)
{
if (segment_state[d] & (1<<s))
{
Segments[s].style.visibility = "hidden";
if (d==3)
led_array[s].checked = false;
}
}
segment_state[d] = 0;
}
}
}
}

// show 7segment data: digit (0..7, left to right)
function show_7segment(digit, value)
{
if (segment_state[digit] == (segment_state[digit]|value))
if (value == 0)
return;
segment_timeout[digit] = 2;
if (value == segment_state[digit])
return;
if (led_selected && (digit==3))
{
Expand All @@ -56,10 +78,7 @@ function show_7segment(digit, value)
var mask = (1<<s);
if ((value & mask) != (segment_state[digit] & mask))
{
if (value & mask)
Segments[s].style.visibility = "visible";
else
Segments[s].style.visibility = "hidden";
Segments[s].style.visibility = (value & mask) ? "visible" : "hidden";
}
}
}
Expand Down
1 change: 1 addition & 0 deletions js/ins8070.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function cpu_reset()
R_PC = 0x1;
R_S = 0x0;
R_SP = 0x0;
Cycles = 0x0;
cpu_show();
}

Expand Down
46 changes: 41 additions & 5 deletions js/mc6400.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var MatrixBitmask = 0; // button and segment matrix selection bitmask
/* I/O write operation. Called from CPU emulator. */
function io_write(adr, value)
{
value = w8(value);
if ((adr&0xFFF0) == 0xFD00)
{
// register
Expand Down Expand Up @@ -110,22 +111,24 @@ var LastDigitsClearedMs = 0;
function cpu_go()
{
var tMs = performance.now();
if (tMs - LastDigitsClearedMs > 200)
if (tMs - LastDigitsClearedMs > 10)
{
clear_digits();
LastDigitsClearedMs = tMs;
}

if ((!Halted)&&(PowerState))
cpu_run(300);
cpu_run(1000);

if ((Halted)||(!PowerState))
{
CpuTimer = null;
clear_digits();
clear_digits(3);
cpu_show();
}
else
CpuTimer = setTimeout(cpu_go, 2);
CpuTimer = setTimeout(cpu_go, 3);
}

/* Halt the CPU execution */
Expand Down Expand Up @@ -197,6 +200,7 @@ function change_power_state(state)
// memory/CPU state lost when power is off
memory_init(false);
cpu_reset();
clear_digits();
}
else
{
Expand All @@ -215,7 +219,7 @@ function power_toggle(id)
function ssdled_toggle()
{
led_selected = !GUI_SSD_LED.checked;
clear_digits();
clear_digits(3);
}

function sensor_input(key, down)
Expand Down Expand Up @@ -271,6 +275,14 @@ function green_button_init()
cell.userdata = (key&7) | (flag << 4);
cell.onmousedown = function() {button_matrix_input(cell.userdata, true);};
cell.onmouseup = function() {button_matrix_input(cell.userdata, false);};

// touch events
cell.addEventListener("touchstart", (event) => {
button_matrix_input(cell.userdata, true);
event.preventDefault();}, false);
cell.addEventListener("touchend", (event) => {
button_matrix_input(cell.userdata, false);
event.preventDefault();}, false);
key++;
}
}
Expand All @@ -296,6 +308,15 @@ function blue_button_init()
cell.userdata = (button_row + button_column*4) | (flag << 4);
cell.onmousedown = function() {button_matrix_input(cell.userdata, true); };
cell.onmouseup = function() {button_matrix_input(cell.userdata, false);};

// touch events
cell.addEventListener("touchstart", (event) => {
button_matrix_input(cell.userdata, true);
event.preventDefault();}, false);
cell.addEventListener("touchend", (event) => {
button_matrix_input(cell.userdata, false);
event.preventDefault();}, false);

button_column++;
}
button_row++;
Expand All @@ -314,8 +335,23 @@ function mc6400_init()
gui("SA").onmouseup = function() { sensor_input("SA", false);}
gui("SB").onmouseup = function() { sensor_input("SB", false);}

// touch events
gui("SA").addEventListener("touchstart", (event) => {
sensor_input("SA", true);
event.preventDefault();}, false);
gui("SA").addEventListener("touchend", (event) => {
sensor_input("SA", false);
event.preventDefault();}, false);
gui("SB").addEventListener("touchstart", (event) => {
sensor_input("SB", true);
event.preventDefault();}, false);
gui("SB").addEventListener("touchend", (event) => {
sensor_input("SB", false);
event.preventDefault();}, false);

GUI_POWER.onchange = power_toggle;
GUI_SSD_LED.onchange = ssdled_toggle;
ssdled_toggle();

BUTTON_CPU_START.onclick = cpu_start;
BUTTON_CPU_HALT.onclick = cpu_halt;
Expand All @@ -328,7 +364,7 @@ function mc6400_init()
load_program(0x0, MC6400_ROM);

cpu_reset();
change_power_state(false);
power_toggle();
}

// initialize the board
Expand Down

0 comments on commit a042966

Please sign in to comment.