Some baby steps with lua: I thought I'd see if I could "dump" the Apple 2 text screen memory to the lua console.


./mame64 apple2e -plugin console


Code
cpu = manager:machine().devices[":maincpu"];mem = cpu.spaces["program"]

for i=0,23 do appletextaddress=0x400+(math.floor(i/8)*40+128*(i%8)); print(i.."  "..appletextaddress.."") end

for i=0,23 do appletextaddress=0x400+(math.floor(i/8)*40+128*(i%8)); a="";for k=0,39 do newchar = mem:read_i8(appletextaddress+k); newchar = newchar & 127 ; if newchar < 32 then newchar = newchar + 64; end; a=a..string.char(newchar); end; print (i.."  "..appletextaddress.." "..a); end


There's a minimal amount of character fixing, just take the char, strip the high bit and turn characters less than 32 into something recognizable by adding 64.


Running the little program:

100 HOME : FOR I = 1 TO 24: HTAB 1 : VTAB I: PRINT "Apple Text Line: ";I;: NEXT : VTAB 1

[Linked Image from i.imgur.com]


Code
0  1024 Apple Text Line: 1                      
1  1152 ]pple Text Line: 2                      
2  1280 Apple Text Line: 3                      
3  1408 Apple Text Line: 4                      
4  1536 Apple Text Line: 5                      
5  1664 Apple Text Line: 6                      
6  1792 Apple Text Line: 7                      
7  1920 Apple Text Line: 8                      
8  1064 Apple Text Line: 9                      
9  1192 Apple Text Line: 10                     
10  1320 Apple Text Line: 11                     
11  1448 Apple Text Line: 12                     
12  1576 Apple Text Line: 13                     
13  1704 Apple Text Line: 14                     
14  1832 Apple Text Line: 15                     
15  1960 Apple Text Line: 16                     
16  1104 Apple Text Line: 17                     
17  1232 Apple Text Line: 18                     
18  1360 Apple Text Line: 19                     
19  1488 Apple Text Line: 20                     
20  1616 Apple Text Line: 21                     
21  1744 Apple Text Line: 22                     
22  1872 Apple Text Line: 23                     
23  2000 Apple Text Line: 24                     

and my UI paste test becomes:

Code
0  1024                                         
1  1152 ]    EXCLAIM!ATSIGNHASH#DOLLARSIGN$PERCE
2  1280 NT%CARETAMPER^ASTERISKLEFTPAREN*RIGHTPAR
3  1408 EN(                                     
4  1536                                         
5  1664 ?SYNTAX ERROR                           
6  1792 ]ASH-UNDERSCORE_PLUS+EQUALS=BRACKET[]CUR
7  1920 LY{}BACKSLASH\VERTICALBAR|              
8  1064                                         
9  1192 ?SYNTAX ERROR                           
10  1320 ]TICK`TILDE~                            
11  1448                                         
12  1576 ?SYNTAX ERROR                           
13  1704 ]    COMMA,PERIOD.LESSTHAN<GREATERTHAN>S
14  1832 LASH/QUESTION?SEMICOLON;COLON:SINGLEQUOT
15  1960 E&DOUBLEQUOTE@                          
16  1104                                         
17  1232 ?SYNTAX ERROR                           
18  1360 ]BCDEFGHIJKLMNOPQRSTUVWXYZ              
19  1488                                         
20  1616 ?SYNTAX ERROR                           
21  1744 ]   ABCDEFGHJIJKLMNOPQRSTUVWXYZ         
22  1872                                         
23  2000