Skip to content

Commit a6f6c0a

Browse files
committed
Added input support
1 parent 4e69dd3 commit a6f6c0a

File tree

14 files changed

+126
-25
lines changed

14 files changed

+126
-25
lines changed

Emulator/SimInst/siminst.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ SIDLLEXPORT byte siRamByte(int offset)
6060
return 0;
6161
}
6262

63+
SIDLLEXPORT void siSetInput(byte inputByte)
64+
{
65+
if (_c)
66+
{
67+
setInput(_c, inputByte);
68+
}
69+
}
70+
71+
6372
// set the clock state (1 = high, 0 = low)
6473
SIDLLEXPORT void siSetClock(int high)
6574
{

Emulator/SimInst/siminst.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ SIDLLEXPORT void siLoadRam(const char* data);
5151

5252
SIDLLEXPORT byte siRamByte(int offset);
5353

54+
SIDLLEXPORT void siSetInput(byte inputByte);
55+
5456
// set the clock state (1 = high, 0 = low)
5557
SIDLLEXPORT void siSetClock(int high);
5658

Emulator/SimLib/computer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ DLLEXPORT byte ramByte(Computer* c, int offset)
106106
return readRam(c->ram, offset);
107107
}
108108

109+
DLLEXPORT void setInput(Computer* c, byte inputByte)
110+
{
111+
setRegisterValue(c->rd, inputByte);
112+
}
113+
109114
DLLEXPORT void computerTick(Computer* c, int high)
110115
{
111116
if (c->controlWord & HLT)

Emulator/SimLib/computer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ DLLEXPORT void loadRam(Computer* c, const char* data);
9393

9494
DLLEXPORT byte ramByte(Computer* c, int offset);
9595

96+
DLLEXPORT void setInput(Computer* c, byte inputByte);
97+
9698
// state: 1 = high, 0 = low
9799
DLLEXPORT void computerTick(Computer* r, int high);
98100

Emulator/SimWasm/cpemu.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Module.expectedDataFileDownloads++;
193193
}
194194

195195
}
196-
loadPackage({"files": [{"start": 0, "audio": 0, "end": 262144, "filename": "/rom.hex"}], "remote_package_size": 262144, "package_uuid": "a8b8d489-2d19-4dce-98ec-03186d9b2fd2"});
196+
loadPackage({"files": [{"start": 0, "audio": 0, "end": 262144, "filename": "/rom.hex"}], "remote_package_size": 262144, "package_uuid": "e9736003-3644-44aa-b990-e2a0245031d7"});
197197

198198
})();
199199

@@ -5488,6 +5488,12 @@ var _simLibSetClock = Module["_simLibSetClock"] = function() {
54885488
return Module["asm"]["_simLibSetClock"].apply(null, arguments)
54895489
};
54905490

5491+
var _simLibSetInput = Module["_simLibSetInput"] = function() {
5492+
assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
5493+
assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
5494+
return Module["asm"]["_simLibSetInput"].apply(null, arguments)
5495+
};
5496+
54915497
var _vrEmuLcdCharBits = Module["_vrEmuLcdCharBits"] = function() {
54925498
assert(runtimeInitialized, 'you need to wait for the runtime to be ready (e.g. wait for main() to be called)');
54935499
assert(!runtimeExited, 'the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)');

Emulator/SimWasm/cpemu.wasm

220 Bytes
Binary file not shown.

Emulator/SimWasm/simwasm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ int simLibRamByte(int offset)
3333
return siRamByte(offset);
3434
}
3535

36+
EMSCRIPTEN_KEEPALIVE
37+
void simLibSetInput(byte inputByte)
38+
{
39+
siSetInput(inputByte);
40+
}
41+
3642
// set the clock state (1 = high, 0 = low)
3743
EMSCRIPTEN_KEEPALIVE
3844
void simLibSetClock(int high)

Emulator/vrEmuLcd

Web/asm/examples/Big Font (LCD).asm

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ _RESETTING = 0x03
6565
jmp start
6666

6767
; the nulll-delimited text to display.
68-
text: #str "DAD SUCKS!!! \0"
68+
text: #str "HTTPS:/CPU.VISUALREALMSOFTWARE.COM \0"
6969

7070

7171
; start of the program
@@ -161,11 +161,18 @@ start:
161161
pop Rc
162162
lcd Rc
163163
164+
data Rb, 100
165+
call delay
166+
164167
data Ra, SCROLL_LEFT
165168
lcc Ra
166169
167170
jmp .loop
168171

172+
delay:
173+
dec Rb
174+
jnz delay
175+
ret
169176

170177
; leftRotate()
171178
; bitwise rotate Rb
@@ -264,14 +271,14 @@ buildCustomCharacters:
264271
; confusion with a null terminator
265272
charData:
266273
; 08 (07)
267-
#d8 0b00011
274+
#d8 0b00001
275+
#d8 0b00011
276+
#d8 0b00011
277+
#d8 0b00111
278+
#d8 0b00111
279+
#d8 0b01111
268280
#d8 0b01111
269281
#d8 0b01111
270-
#d8 0b11111
271-
#d8 0b11111
272-
#d8 0b11111
273-
#d8 0b11111
274-
#d8 0b11111
275282

276283
; 01 (06)
277284
#d8 0b11111
@@ -284,14 +291,14 @@ charData:
284291
#d8 0b11111
285292

286293
; 02 (05)
294+
#d8 0b10000
295+
#d8 0b11000
287296
#d8 0b11000
297+
#d8 0b11100
298+
#d8 0b11100
299+
#d8 0b11110
288300
#d8 0b11110
289301
#d8 0b11110
290-
#d8 0b11111
291-
#d8 0b11111
292-
#d8 0b11111
293-
#d8 0b11111
294-
#d8 0b11111
295302

296303
; 03 (04)
297304
#d8 0b11111
@@ -332,7 +339,7 @@ bin PLUS ; +
332339
bin NULL ; ,
333340
bin MINUS ; -
334341
bin STOP ; .
335-
bin NULL ; /
342+
bin SLASH ; /
336343
bin ZERO ; 0
337344
bin ONE ; 1
338345
bin TWO ; 2
@@ -395,12 +402,14 @@ SPACE: #d16 0xee00
395402
EXCLAMATION: #d16 0xf600
396403
DOUBLE_QUOTE: ;#d32 0x3eee3e00
397404
SINGLE_QUOTE: #d16 0x3e00
398-
OPEN_BRACKET: #d24 0x873400
399-
CLOSE_BRACKET: #d24 0x342500
405+
OPEN_BRACKET: #d16 0x4e00;24 0x873400
406+
CLOSE_BRACKET: #d16 0xe300;24 0x342500
400407
PLUS: #d32 0x43ff4300
401408

402409
MINUS: #d32 0x43434300
403410
STOP: #d16 0xe400
411+
SLASH: ;#d32 0xe8855e00
412+
SLASHES: #d48 0xe88558855e00
404413
ZERO: #d32 0x87342500
405414
ONE: #d32 0x34ffe400
406415
TWO: #d32 0x17142400

Web/asm/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function setupEditor() {
7373
example = "Fibonacci";
7474
}
7575

76-
loadProgramFile("examples/" + example + ".asm");
76+
loadProgramFile("examples/" + example.replace("+"," ") + ".asm");
7777
}
7878

7979

0 commit comments

Comments
 (0)