mirror of
https://github.com/rzzzwilson/pymlac.git
synced 2025-06-10 09:32:41 +00:00
Removed old test code
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
#
|
||||
# Special Makefile to refresh the good_*.trace file contents
|
||||
# when we make a change to the format, etc.
|
||||
#
|
||||
|
||||
TESTS = $(shell ls test_*.asm|sed -e "s/\.asm//")
|
||||
|
||||
test: $(TESTS)
|
||||
|
||||
%: %.ptp
|
||||
./pymlac -b ptr -ptr $< -r 040 -t 0100 -r 0100
|
||||
mv pymlac.trace good_$*.trace
|
||||
|
||||
%.ptp: %.asm
|
||||
./iasm -l $*.lst $<
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the PTR instructions
|
||||
; we assume a *.ptp file is mounted
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; turn on PTR, read 3 chars
|
||||
lwc 3 ;
|
||||
dac lcount ;
|
||||
hon ;
|
||||
loop hsf ;
|
||||
jmp loop ;
|
||||
cla ;
|
||||
hrb ;
|
||||
nop ;
|
||||
loop2 hsn ;
|
||||
jmp loop2 ;
|
||||
isz lcount ;
|
||||
jmp loop ;
|
||||
hof ;
|
||||
hlt ;
|
||||
; data
|
||||
lcount data 0 ;
|
||||
end
|
||||
@@ -1,55 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the ADD instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple ADD
|
||||
law 0 ;
|
||||
add zero ;
|
||||
sam zero ; 0 + 0 -> 0
|
||||
hlt ;
|
||||
law 0 ;
|
||||
add one ;
|
||||
sam one ; 0 + 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
add one ;
|
||||
sam two ; 1 + 1 -> 2
|
||||
hlt ;
|
||||
cll ;
|
||||
lwc 2 ;
|
||||
add one ;
|
||||
sam minus1 ; -2 + 1 -> -1
|
||||
hlt ;
|
||||
add one ;
|
||||
sam zero ; -1 + 1 -> -0
|
||||
hlt ;
|
||||
; now some indirect ADDs
|
||||
law 0 ;
|
||||
add *indzero;
|
||||
sam zero ; 0 + 0 -> 0
|
||||
hlt ;
|
||||
law 0 ;
|
||||
add *indone ;
|
||||
sam one ; 0 + 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
add *indone ;
|
||||
sam two ; 1 + 1 -> 2
|
||||
hlt ;
|
||||
lwc 2 ;
|
||||
add *indone ;
|
||||
sam minus1 ; -2 + 1 -> -1
|
||||
hlt ;
|
||||
add *indone ;
|
||||
sam zero ; -1 + 1 -> -0
|
||||
hlt ;
|
||||
hlt ;
|
||||
;
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
two data 2 ;
|
||||
minus1 data 0177777 ;
|
||||
indone data one ;
|
||||
indzero data zero ;
|
||||
hibit data 0100000 ; just high bit
|
||||
end
|
||||
@@ -1,40 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the AND instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple AND
|
||||
lac minus1 ;
|
||||
and one ;
|
||||
sam one ; -1 & 1 -> 1
|
||||
hlt ;
|
||||
law 010 ;
|
||||
and one ;
|
||||
sam zero ; 010 & 1 -> 0
|
||||
hlt ;
|
||||
law 02 ;
|
||||
and two ;
|
||||
sam two ; 02 & 2 -> 2
|
||||
hlt ;
|
||||
lac minus1 ; -1 & 0100000 -> 0100000
|
||||
and hibit ;
|
||||
sam hibit ;
|
||||
hlt ;
|
||||
; now some indirect ANDs
|
||||
lac minus1 ;
|
||||
and *indm1 ;
|
||||
sam minus1 ;
|
||||
hlt ;
|
||||
lac minus1 ;
|
||||
and *ind0 ;
|
||||
sam zero ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
;
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
two data 2 ;
|
||||
minus1 data 0177777 ;
|
||||
indm1 data minus1 ;
|
||||
ind0 data zero ;
|
||||
hibit data 0100000 ; just high bit
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test the use of bank addresses
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
lac exp ; put value in high memory
|
||||
dac *ihigha ;
|
||||
cla ;
|
||||
lac *ihigha ;
|
||||
sam exp
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data
|
||||
ihigha data 010000 ;
|
||||
exp data 012345 ;
|
||||
end
|
||||
@@ -1,72 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test the conditional skip instructions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check ASZ - skip if AC is zero
|
||||
lwc 1 ; AC <- 0177777 (-1)
|
||||
asz ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
asz ; should skip
|
||||
hlt ;
|
||||
|
||||
; check ASN - skip if AC is not zero
|
||||
lwc 1 ; AC <- 0177777 (-1)
|
||||
asn ; should skip
|
||||
hlt ;
|
||||
law 0 ;
|
||||
asn ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
|
||||
; check ASP - skip if AC is a positive number
|
||||
; zero is positive here, as the test is for bit 0 set
|
||||
law 0 ; AC <- 0
|
||||
asp ; should skip
|
||||
hlt ;
|
||||
law 1 ; AC <- 1
|
||||
asp ; should skip
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
asp ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
|
||||
; check ASM - skip if AC is a negative number
|
||||
; zero is positive here, as the test is for bit 0 set
|
||||
law 0 ; AC <- 0
|
||||
asm ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
law 1 ; AC <- 1
|
||||
asm ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
asm ; should skip
|
||||
hlt ;
|
||||
|
||||
; check LSZ - skip if L is zero
|
||||
stl ; L <- 1
|
||||
lsz ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
lsz ; should skip
|
||||
hlt ;
|
||||
|
||||
; check LSN - skip if L is not zero
|
||||
stl ; L <- 1
|
||||
lsn ; should skip
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
lsn ; should not skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
|
||||
; can't easily test DSF, DSN, KSF, KSN, RSF, RSN,
|
||||
; TSF, TSN, SSF, SSN, HSF, HSN as they test hardware
|
||||
|
||||
hlt ;
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test DAC instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple DAC
|
||||
lwc 1 ; AC <- 0177777 (-1)
|
||||
dac dactest ; store
|
||||
cla ; clear AC
|
||||
lac dactest ; did we store -1?
|
||||
sam minus1 ; skip if so
|
||||
hlt ;
|
||||
; check indirect DAC
|
||||
lwc 2 ; AC <- 0177776 (-2)
|
||||
dac *inddac ; store indirect to dactest
|
||||
cla ; clear AC
|
||||
lac dactest ; did we store -2?
|
||||
sam minus2 ; skip if so
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
dactest data 0 ;
|
||||
minus1 data 0177777 ;
|
||||
minus2 data 0177776 ;
|
||||
inddac data dactest ;
|
||||
end
|
||||
@@ -1,47 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test the increment registers (010 -> 017)
|
||||
; indirect access through the inc registers
|
||||
; increments the register and the new value is
|
||||
; the effective address
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
law buff ;
|
||||
dac 010 ; point 010 at 'buff'
|
||||
law 0123 ;
|
||||
dac *010 ;
|
||||
lac 010 ;
|
||||
sam exp1 ;
|
||||
hlt ;
|
||||
law 0123 ;
|
||||
dac *010 ;
|
||||
lac 010 ;
|
||||
sam exp2 ;
|
||||
hlt ;
|
||||
law 0123 ;
|
||||
dac *010 ;
|
||||
lac 010 ;
|
||||
sam exp3 ;
|
||||
hlt ;
|
||||
; now check that value in first three addresses from 'buff'
|
||||
lac buff1 ;
|
||||
sam exp ;
|
||||
hlt ;
|
||||
lac buff2 ;
|
||||
sam exp ;
|
||||
hlt ;
|
||||
lac buff3 ;
|
||||
sam exp ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data
|
||||
exp data 0123 ;
|
||||
exp1 data buff1 ;
|
||||
exp2 data buff2 ;
|
||||
exp3 data buff3 ;
|
||||
|
||||
org 01000
|
||||
buff data 0 ;
|
||||
buff1 data 0 ;
|
||||
buff2 data 0 ;
|
||||
buff3 data 0 ;
|
||||
end
|
||||
@@ -1,77 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the IOR instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple IOR
|
||||
law 0 ;
|
||||
ior one ;
|
||||
sam one ; 0 | 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
ior zero ;
|
||||
sam one ; 1 | 0 -> 1
|
||||
hlt ;
|
||||
lac hbit ;
|
||||
ior one ;
|
||||
sam hbit1 ; 0100000 | 1 -> 0100001
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
ior hamask ;
|
||||
sam hares ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
ior lamask ;
|
||||
sam lares ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
ior hamask ;
|
||||
sam hamask ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
ior lamask ;
|
||||
sam lamask ;
|
||||
hlt ;
|
||||
; now some indirect IORs
|
||||
law 0 ;
|
||||
ior *indone ;
|
||||
sam one ; 0 | 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
ior *indzero;
|
||||
sam one ; 1 | 0 -> 1
|
||||
hlt ;
|
||||
lac hbit ;
|
||||
ior *indone ;
|
||||
sam hbit1 ; 0100000 | 1 -> 0100001
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
ior *indham ;
|
||||
sam hares ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
ior *indlam ;
|
||||
sam lares ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
ior *indham ;
|
||||
sam hamask ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
ior *indlam ;
|
||||
sam lamask ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
hbit data 0100000 ; just high bit
|
||||
hbit1 data 0100001 ; high bit plus 1
|
||||
hamask data 0125252 ; 1010101010101010
|
||||
lamask data 0052525 ; 0101010101010101
|
||||
hares data 0177777 ; 1111111111111111
|
||||
lares data 0177777 ; 1111111111111111
|
||||
indzero data zero ;
|
||||
indone data one ;
|
||||
indham data hamask ;
|
||||
indlam data lamask ;
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test ISZ instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple ISZ
|
||||
lwc 2 ; put -2 into ISZ target
|
||||
dac isztest ;
|
||||
isz isztest ; first ISZ, isztest <- -1, no skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
isz isztest ; second ISZ, isztest <- 0, skip
|
||||
hlt ;
|
||||
; check indirect ISZ
|
||||
lwc 2 ; put -2 into ISZ target
|
||||
dac isztest ;
|
||||
isz *indisz ; first ISZ, *indisz <- -1, no skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
isz *indisz ; second ISZ, *indisz <- 0, skip
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
isztest data 0 ;
|
||||
indisz data isztest ;
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test the JMP instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple JMP
|
||||
jmp jtest ;
|
||||
hlt ;
|
||||
jtest nop ;
|
||||
; now test jump backwards
|
||||
jmp j1 ;
|
||||
j0 jmp j2 ;
|
||||
hlt ;
|
||||
j1 jmp j0 ;
|
||||
hlt ;
|
||||
j2 nop ;
|
||||
; now test indirect JMP
|
||||
jmp *indjmp ;
|
||||
hlt ;
|
||||
target hlt ;
|
||||
; data for test
|
||||
indjmp data target ;
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test JMS instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple JMS
|
||||
jms jmstest ; call test, AC contains return address
|
||||
here sam retadr ; skip if so
|
||||
hlt ;
|
||||
lac jmstest ; make sure saved return address is correct
|
||||
sam retadr ;
|
||||
hlt ;
|
||||
; check indirect JMS
|
||||
test2 jms *indjms ; call same test, AC=return address
|
||||
here2 sam retadr2 ; skip if so
|
||||
hlt ;
|
||||
lac jmstest ; make sure saved return address is correct
|
||||
sam retadr2 ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
; test routine for JMS - returns return address
|
||||
jmstest data 0 ;
|
||||
lac jmstest ; return with AC holding return address
|
||||
jmp *jmstest;
|
||||
; data for tests
|
||||
retadr data here ;
|
||||
retadr2 data here2 ;
|
||||
indjms data jmstest ;
|
||||
end
|
||||
@@ -1,33 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check LAC instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple LAC
|
||||
lac zero ; load AC with 0
|
||||
sam zero ; check it's actually 0
|
||||
hlt ;
|
||||
lac one ; load AC with 1
|
||||
sam one ; check it's actually 1
|
||||
hlt ;
|
||||
lac minus1 ; load AC with -1 (0177777)
|
||||
sam minus1 ; check it's actually -1
|
||||
hlt ;
|
||||
; check indirect LAC
|
||||
lac *indzero; load AC with 0
|
||||
sam zero ; check it's actually 0
|
||||
hlt ;
|
||||
lac *indone ; load AC with 1
|
||||
sam one ; check it's actually 1
|
||||
hlt ;
|
||||
lac *indm1 ; load AC with -1 (0177777)
|
||||
sam minus1 ; check it's actually -1
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
minus1 data 0177777 ;
|
||||
indzero data zero ;
|
||||
indone data one ;
|
||||
indm1 data minus1 ;
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check LAW instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple LAW
|
||||
law 0 ; load AC with 0
|
||||
sam zero ; check it's actually 0
|
||||
hlt ;
|
||||
law 1 ; load AC with 1
|
||||
sam one ; check it's actually 1
|
||||
hlt ;
|
||||
law 2 ; load AC with 2
|
||||
sam two ; check it's actually 2
|
||||
hlt ;
|
||||
law 03777 ; load AC with 11-bit ones
|
||||
sam max ; check it's actually 03777
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
two data 2 ;
|
||||
max data 03777 ;
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test the block loaderible
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
cla ; clear AC
|
||||
lac *t1 ; load high mem indirectly
|
||||
sam expt1 ; skip is as expected
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data
|
||||
t1 data hit1 ;
|
||||
expt1 data 0123 ;
|
||||
|
||||
org 05000 ; in high memory (> 11bit address)
|
||||
hit1 data 0123 ;
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check LWC instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple LWC
|
||||
lwc 0 ; load AC with complement of 0
|
||||
sam zero ; check -0 is 0
|
||||
hlt ;
|
||||
lwc 1 ; load AC with complement of 1
|
||||
sam minus1 ; check -1 is 0177777
|
||||
hlt ;
|
||||
lwc 2 ; load AC with complement of 2
|
||||
sam minus2 ; check -2 is 0177776
|
||||
hlt ;
|
||||
lwc 03777 ; load AC with complement of 03777
|
||||
sam mmax ; check we have complement of 03777
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for test
|
||||
zero data 0 ;
|
||||
minus1 data 0177777 ;
|
||||
minus2 data 0177776 ;
|
||||
mmax data 0174001 ;
|
||||
end
|
||||
@@ -1,64 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the microcoded instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple 'known' instructions
|
||||
lwc 1 ;
|
||||
nop ; NOP - no change
|
||||
cla ; CLA - AC -> 0
|
||||
sam zero ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
cma ; CMA - AC -> 0
|
||||
sam zero ;
|
||||
hlt ;
|
||||
cla ;
|
||||
cma ; CMA - AC -> 0177777
|
||||
sam minus1 ;
|
||||
hlt ;
|
||||
sta ; STA - AC -> 0177777
|
||||
sam minus1 ;
|
||||
hlt ;
|
||||
law 0 ;
|
||||
iac ; IAC - AC -> 1
|
||||
sam one ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
iac ; IAC - AC -> 0, L complemented
|
||||
sam zero ;
|
||||
hlt ;
|
||||
lwc 0 ;
|
||||
coa ; COA - AC -> 1
|
||||
sam one ;
|
||||
hlt ;
|
||||
cia ; CIA - AC -> 0177777
|
||||
sam minus1 ;
|
||||
hlt ;
|
||||
cll ; CLL - L -> 0
|
||||
lsz ; skip if link is zero
|
||||
hlt ;
|
||||
cml ; CML - L -> 1
|
||||
lsn ; skip if L not 0
|
||||
hlt ;
|
||||
cal ; CAL - AC->0, L->0
|
||||
sam zero ;
|
||||
hlt ;
|
||||
lsz ; skip if link is zero
|
||||
hlt ;
|
||||
stl ; STL - L->1
|
||||
lsn ; skip if L not 0
|
||||
hlt ;
|
||||
; now for some unknown compound instructions
|
||||
data 0100007 ; clr AC, ~AC, ++AC
|
||||
sam zero ; AC should be 0
|
||||
hlt ;
|
||||
hlt ;
|
||||
; test ODA and LDA instrunction
|
||||
;
|
||||
; DO THIS ONCE WE CAN RELIABLY SET DATA SWITCHES
|
||||
;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
minus1 data 0177777 ;
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the SAM instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple SAM
|
||||
law 0 ;
|
||||
sam zero ; should skip
|
||||
hlt ;
|
||||
law 0 ;
|
||||
sam one ; should NOT skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
sam minus1 ; should skip
|
||||
hlt ;
|
||||
law 0 ;
|
||||
sam minus1 ; should NOT skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
; now some indirect SAMs
|
||||
law 0 ;
|
||||
sam *indzero; should skip
|
||||
hlt ;
|
||||
law 0 ;
|
||||
sam *indone ; should NOT skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
sam *indm1 ; should skip
|
||||
hlt ;
|
||||
law 0 ;
|
||||
sam *indm1 ; should NOT skip
|
||||
jmp .+2 ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
;
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
minus1 data 0177777 ;
|
||||
indone data one ;
|
||||
indzero data zero ;
|
||||
indm1 data minus1 ;
|
||||
end
|
||||
@@ -1,179 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the shift and rotate instructions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, SAL instruction
|
||||
stl ; L <-1
|
||||
lwc 1 ; AC <- 0177777
|
||||
sal 1 ; AC <- 0177776, L unchanged
|
||||
sam sal11 ;
|
||||
hlt ;
|
||||
lsn ; link should still be 1
|
||||
hlt ; error, was 0
|
||||
cll ; L <- 0
|
||||
lwc 1 ; AC <- 0177777
|
||||
sal 2 ; AC <- 0177774, L unchanged
|
||||
sam sal12 ;
|
||||
hlt ;
|
||||
lsz ; link should still be 0
|
||||
hlt ; error, was 1
|
||||
lwc 1 ;
|
||||
sal 3 ; AC <- 0177770
|
||||
sam sal13 ;
|
||||
hlt ;
|
||||
lac sal21b ; AC <- 0100001
|
||||
sal 1 ; AC <- 0100002
|
||||
sam sal21 ;
|
||||
hlt ;
|
||||
lac sal21b ; AC <- 0100001
|
||||
sal 2 ; AC <- 0100004
|
||||
sam sal22 ;
|
||||
hlt ;
|
||||
lac sal21b ; AC <- 0100001
|
||||
sal 3 ; AC <- 0100010
|
||||
sam sal23 ;
|
||||
hlt ;
|
||||
lsz ; link should still be 0
|
||||
hlt ; error, was 1
|
||||
; now test SAR
|
||||
stl ; L <- 1
|
||||
lwc 1 ; AC <- 0177777
|
||||
sar 1 ; AC <- 0177777
|
||||
sam sar11 ;
|
||||
hlt ;
|
||||
lsn ; L should still be 1
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
lwc 1 ;
|
||||
sar 2 ; AC <- 0177777
|
||||
sam sar12 ;
|
||||
hlt ;
|
||||
lsz ; L should still be 0
|
||||
hlt ;
|
||||
lwc 1 ;
|
||||
sar 3 ; AC <- 0177777
|
||||
sam sar13 ;
|
||||
hlt ;
|
||||
lac sar21b ; AC <- 0077777
|
||||
sar 1 ; AC <- 0037777
|
||||
sam sar21 ;
|
||||
hlt ;
|
||||
lac sar21b ;
|
||||
sar 2 ; AC <- 0017777
|
||||
sam sar22 ;
|
||||
hlt ;
|
||||
lac sar21b ;
|
||||
sar 3 ; AC <- 0007777
|
||||
sam sar23 ;
|
||||
hlt ;
|
||||
; test the RAR instruction
|
||||
cll ; L <- 0
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 1 ; AC <- 0040000
|
||||
sam rar11 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 2 ; AC <- 0020000
|
||||
sam rar12 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 3 ; AC <- 0010000
|
||||
sam rar13 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 1 ; AC <- 0140000
|
||||
sam rar21 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 2 ; AC <- 0060000
|
||||
sam rar22 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
lac rar11b ; AC <- 0100000
|
||||
rar 3 ; AC <- 0030000
|
||||
sam rar23 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
law 3 ; AC <- 0000003
|
||||
rar 1 ; L <- 1 AC <- 0000001
|
||||
sam rar24 ;
|
||||
hlt ;
|
||||
lsn ; L should be 1
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
law 3 ; AC <- 0000003
|
||||
rar 1 ; L <- 1 AC <- 0100001
|
||||
sam rar25 ;
|
||||
hlt ;
|
||||
lsn ; L should be 1
|
||||
hlt ;
|
||||
; test the RAL instruction
|
||||
cll ; L <- 0
|
||||
lac ral11b ; AC <- 0100001
|
||||
ral 1 ; L <- 1 AC <- 0000002
|
||||
sam ral11 ;
|
||||
hlt ;
|
||||
lsn ; L should be 1
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
lac ral11b ; AC <- 0100001
|
||||
ral 1 ; L <- 1 AC <- 0000003
|
||||
sam ral12 ;
|
||||
hlt ;
|
||||
lsn ; L should be 1
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
lac ral11c ; AC <- 0000001
|
||||
ral 1 ; L <- 0 AC <- 0000003
|
||||
sam ral12 ;
|
||||
hlt ;
|
||||
lsz ; L should be 0
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
sal11 data 0177776 ;
|
||||
sal12 data 0177774 ;
|
||||
sal13 data 0177770 ;
|
||||
sal21b data 0100001 ;
|
||||
sal21 data 0100002 ;
|
||||
sal22 data 0100004 ;
|
||||
sal23 data 0100010 ;
|
||||
sar11 data 0177777 ;
|
||||
sar12 data 0177777 ;
|
||||
sar13 data 0177777 ;
|
||||
sar21b data 0077777 ;
|
||||
sar21 data 0037777 ;
|
||||
sar22 data 0017777 ;
|
||||
sar23 data 0007777 ;
|
||||
rar11b data 0100000 ;
|
||||
rar11 data 0040000 ;
|
||||
rar12 data 0020000 ;
|
||||
rar13 data 0010000 ;
|
||||
rar21 data 0140000 ;
|
||||
rar22 data 0060000 ;
|
||||
rar23 data 0030000 ;
|
||||
rar24 data 0000001 ;
|
||||
rar25 data 0100001 ;
|
||||
ral11b data 0100001 ;
|
||||
ral11c data 0000001 ;
|
||||
ral11 data 0000002 ;
|
||||
ral12 data 0000003 ;
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; smallest program possible
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
hlt ;
|
||||
end
|
||||
@@ -1,66 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the SUB instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple SUB
|
||||
law 0 ;
|
||||
sub zero ;
|
||||
sam zero ; 0 - 0 -> 0
|
||||
hlt ;
|
||||
law 1 ;
|
||||
sub zero ;
|
||||
sam one ; 1 - 0 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
sub one ;
|
||||
sam zero ; 1 - 1 -> 0
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
law 0 ;
|
||||
sub one ;
|
||||
sam minus1 ; 0 - 1 -> -1
|
||||
hlt ;
|
||||
lsn ; link should be 1
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
law 0 ;
|
||||
sub one ;
|
||||
sam minus1 ; 0 - 1 -> -1
|
||||
hlt ;
|
||||
lsz ; link should be 0
|
||||
hlt ;
|
||||
; now some indirect SUBs
|
||||
law 0 ;
|
||||
sub *indzero;
|
||||
sam zero ; 0 - 0 -> 0
|
||||
hlt ;
|
||||
law 1 ;
|
||||
sub *indzero;
|
||||
sam one ; 1 - 0 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
sub *indone ;
|
||||
sam zero ; 1 - 1 -> 0
|
||||
hlt ;
|
||||
cll ; L <- 0
|
||||
law 0 ;
|
||||
sub *indone ;
|
||||
sam minus1 ; 0 - 1 -> -1
|
||||
hlt ;
|
||||
lsn ; link should be 1
|
||||
hlt ;
|
||||
stl ; L <- 1
|
||||
law 0 ;
|
||||
sub *indone ;
|
||||
sam minus1 ; 0 - 1 -> -1
|
||||
hlt ;
|
||||
lsz ; link should be 0
|
||||
hlt ;
|
||||
hlt ;
|
||||
;
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
minus1 data 0177777 ;
|
||||
indone data one ;
|
||||
indzero data zero ;
|
||||
end
|
||||
@@ -1,36 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; test XAM instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; check simple XAM
|
||||
stl ; L <- 1
|
||||
law 0 ;
|
||||
dac xamtest ;
|
||||
lwc 1 ; AC <- 0177777 (-1)
|
||||
xam xamtest ; switch with xamtest
|
||||
sam zero ; test AC is 0
|
||||
hlt ;
|
||||
lsn ; L should still be 1
|
||||
hlt ;
|
||||
lwc 1 ; check xamtest is -1
|
||||
sam xamtest ;
|
||||
hlt ;
|
||||
; check indirect XAM
|
||||
cll ; L <- 0
|
||||
law 0 ;
|
||||
dac xamtest ;
|
||||
lwc 1 ; AC <- 0177777 (-1)
|
||||
xam *indxam ; switch with xamtest (indirect)
|
||||
sam zero ; test AC is 0
|
||||
hlt ;
|
||||
lsz ; L is still 0?
|
||||
hlt ;
|
||||
lwc 1 ; check xamtest is -1
|
||||
sam xamtest ;
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
xamtest data 0 ;
|
||||
zero data 0 ;
|
||||
indxam data xamtest ;
|
||||
end
|
||||
@@ -1,48 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; check the XOR instruction
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
org 00100
|
||||
; first, simple XOR
|
||||
law 0 ;
|
||||
xor one ;
|
||||
sam one ; 0 ^ 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
xor one ;
|
||||
sam zero ; 1 ^ 1 -> 0
|
||||
hlt ;
|
||||
law 1 ;
|
||||
xor zero ;
|
||||
sam one ; 1 ^ 0 -> 1
|
||||
hlt ;
|
||||
lac minus1 ;
|
||||
xor one ;
|
||||
sam hbit0 ; 0177777 ^ 1 -> 0177776
|
||||
hlt ;
|
||||
; now some indirect XORs
|
||||
law 0 ;
|
||||
xor *indone ;
|
||||
sam one ; 0 ^ 1 -> 1
|
||||
hlt ;
|
||||
law 1 ;
|
||||
xor *indone ;
|
||||
sam zero ; 1 ^ 1 -> 0
|
||||
hlt ;
|
||||
law 1 ;
|
||||
xor *indzero;
|
||||
sam one ; 1 ^ 0 -> 1
|
||||
hlt ;
|
||||
lac minus1 ;
|
||||
xor *indone ;
|
||||
sam hbit0 ; 0177777 ^ 1 -> 0177776
|
||||
hlt ;
|
||||
hlt ;
|
||||
; data for tests
|
||||
zero data 0 ;
|
||||
one data 1 ;
|
||||
minus1 data 0177777 ;
|
||||
hbit data 0100000 ; just high bit
|
||||
hbit0 data 0177776 ; all set except bit 15
|
||||
indzero data zero ;
|
||||
indone data one ;
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# global instruction cycle counter
|
||||
global instruction_cycles
|
||||
instruction_cycles = 0
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#from Globals import *
|
||||
|
||||
class Test1(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def alpha(self):
|
||||
global instruction_cycles
|
||||
instruction_cycles += 2
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
import sys
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
class Test(object):
|
||||
def __init__(self):
|
||||
self.event = pygame.event.Event(USEREVENT + 1, mystr="test event")
|
||||
self.count = 100000
|
||||
|
||||
def test(self):
|
||||
self.count -= 1
|
||||
if self.count < 0:
|
||||
self.count = 100000
|
||||
pygame.event.post(self.event)
|
||||
|
||||
def main():
|
||||
test = Test()
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((100,100))
|
||||
|
||||
while 1:
|
||||
test.test()
|
||||
for event in pygame.event.get():
|
||||
if event.type == USEREVENT + 1:
|
||||
print event.dict["mystr"]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,544 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
########################################################################################################
|
||||
# For handling filenames...
|
||||
import os, time, sys
|
||||
|
||||
# The pygame module itself...
|
||||
import pygame
|
||||
|
||||
# The image handling...
|
||||
import pygame.image
|
||||
|
||||
# Important constant definitions for Pygame,
|
||||
# in this example: used to setup the "Double Buffered" Display...
|
||||
from pygame.locals import *
|
||||
|
||||
# Initialise SDL environment
|
||||
pygame.init()
|
||||
|
||||
# Get the image from: ./images/pygamelogo1.gif
|
||||
#panel_file = os.path.join('images', 'panel.png')
|
||||
#led_on_file = os.path.join('images', 'led_on.png')
|
||||
#led_off_file = os.path.join('images', 'led_off.png')
|
||||
|
||||
ITEM_HEIGHT = 17
|
||||
DEVICEMENU = ('Mount', 'Dismount', 'Rewind', 'Turn on', 'Turn off')
|
||||
|
||||
snapshot_file = 'pymlac_snap.bmp'
|
||||
|
||||
BLACK = (0,0,0)
|
||||
WHITE = (255,255,255)
|
||||
YELLOW = (255,255,64)
|
||||
GREY = (128,128,128)
|
||||
LIGHTGREY = (182,182,182)
|
||||
RED = (128, 0, 0)
|
||||
|
||||
VERSION_POSN = (173,0)
|
||||
|
||||
CANVAS_WIDTH = 1024
|
||||
CANVAS_HEIGHT = 1024
|
||||
|
||||
BOX_POSNX = 5
|
||||
BOX_POSNY = 45
|
||||
BOX_OFFSETY = 42
|
||||
BOX_WIDTH = 246
|
||||
BOX_HEIGHT = 20
|
||||
LABEL_OFFSETY = -19
|
||||
EOF_OFFSETX = CANVAS_WIDTH + BOX_POSNX + 180
|
||||
TAGS_OFFSETY = -17
|
||||
ON_OFFSETX = 1254
|
||||
OFF_OFFSETX = 1247
|
||||
FILE_OFSETX = 1032
|
||||
FILE_OFFSETY = +1
|
||||
|
||||
PTR_BOX_POSNY = BOX_POSNY
|
||||
PTR_LABEL_POSN = (BOX_POSNX, PTR_BOX_POSNY + LABEL_OFFSETY)
|
||||
PTR_EOF_POSN = (EOF_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_ON_POSN = (ON_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_OFF_POSN = (OFF_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_FILE_POSN = (FILE_OFSETX, PTR_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
PTP_BOX_POSNY = PTR_BOX_POSNY + BOX_OFFSETY
|
||||
PTP_LABEL_POSN = (BOX_POSNX, PTP_BOX_POSNY + LABEL_OFFSETY)
|
||||
PTP_EOF_POSN = (EOF_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_ON_POSN = (ON_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_OFF_POSN = (OFF_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_FILE_POSN = (FILE_OFSETX, PTP_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
TTYIN_BOX_POSNY = PTP_BOX_POSNY + BOX_OFFSETY
|
||||
TTYIN_LABEL_POSN = (BOX_POSNX, TTYIN_BOX_POSNY + LABEL_OFFSETY)
|
||||
TTYIN_EOF_POSN = (EOF_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_ON_POSN = (ON_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_OFF_POSN = (OFF_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_FILE_POSN = (FILE_OFSETX, TTYIN_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
TTYOUT_BOX_POSNY = TTYIN_BOX_POSNY + BOX_OFFSETY
|
||||
TTYOUT_LABEL_POSN = (BOX_POSNX, TTYOUT_BOX_POSNY + LABEL_OFFSETY)
|
||||
TTYOUT_EOF_POSN = (EOF_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_ON_POSN = (ON_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_OFF_POSN = (OFF_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_FILE_POSN = (FILE_OFSETX, TTYOUT_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
LEDAC_LABEL_OFFSETY = -18
|
||||
LEDL_POSNX = 0
|
||||
LEDAC_POSNX = 17
|
||||
LEDAC_POSNY = 715
|
||||
LEDPC_LABEL_OFFSETY = -18
|
||||
LEDPC_POSNX = 17
|
||||
LEDPC_POSNY = LEDAC_POSNY + 35
|
||||
LED_BIT_OFFSETX = 15
|
||||
LED_BIT_RANGE = (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
|
||||
LEDL_SCREEN_POSNX = CANVAS_WIDTH + LEDL_POSNX
|
||||
LEDAC_SCREEN_POSNX = CANVAS_WIDTH + LEDAC_POSNX
|
||||
LEDAC_SCREEN_POSNY = LEDAC_POSNY
|
||||
|
||||
LEDPC_SCREEN_POSNX = CANVAS_WIDTH + LEDPC_POSNX
|
||||
LEDPC_SCREEN_POSNY = LEDPC_POSNY
|
||||
|
||||
PANEL_WIDTH = 256
|
||||
|
||||
REGS_MON_DIVIDERY = 205
|
||||
ROM_MON_DIVIDERY = 285
|
||||
FILE_ROM_DIVIDER = 690
|
||||
MON_LED_DIVIDERY = 775
|
||||
BOX_BOT_DIVIDERY = 875
|
||||
|
||||
BOX_POSNY = 802
|
||||
|
||||
REGL_BOX_POSNX = 73
|
||||
REGL_BOX_POSNY = BOX_POSNY
|
||||
REGL_BOX_WIDTH = 15
|
||||
REGL_BOX_HEIGHT = 20
|
||||
|
||||
REGAC_BOX_POSNX = 95
|
||||
REGAC_BOX_POSNY = REGL_BOX_POSNY
|
||||
REGAC_BOX_WIDTH = 55
|
||||
REGAC_BOX_HEIGHT = 20
|
||||
|
||||
REGPC_BOX_POSNX = 170
|
||||
REGPC_BOX_POSNY = REGL_BOX_POSNY
|
||||
REGPC_BOX_WIDTH = 55
|
||||
REGPC_BOX_HEIGHT = 20
|
||||
|
||||
REGDX_BOX_POSNX = 33
|
||||
REGDX_BOX_POSNY = BOX_POSNY + 40
|
||||
REGDX_BOX_WIDTH = 55
|
||||
REGDX_BOX_HEIGHT = 20
|
||||
|
||||
REGDY_BOX_POSNX = 95
|
||||
REGDY_BOX_POSNY = REGDX_BOX_POSNY
|
||||
REGDY_BOX_WIDTH = 55
|
||||
REGDY_BOX_HEIGHT = 20
|
||||
|
||||
REGDPC_BOX_POSNX = 170
|
||||
REGDPC_BOX_POSNY = REGDX_BOX_POSNY
|
||||
REGDPC_BOX_WIDTH = 55
|
||||
REGDPC_BOX_HEIGHT = 20
|
||||
|
||||
BOX_DATA_OFFSETX = 4
|
||||
BOX_DATA_OFFSETY = 2
|
||||
|
||||
BOOTROM_POSNX = 10
|
||||
BOOTROM_POSNY = 215
|
||||
|
||||
BOOTROM_LABEL_POSN = (BOOTROM_POSNX, BOOTROM_POSNY)
|
||||
BOOTROM_LOADPTR_RADIO_POSN = (BOOTROM_POSNX + 5, BOOTROM_POSNY + 20)
|
||||
BOOTROM_LOADPTR_LABEL_POSN = (BOOTROM_POSNX + 28, BOOTROM_POSNY + 18)
|
||||
BOOTROM_LOADTTY_RADIO_POSN = (BOOTROM_POSNX + 5, BOOTROM_POSNY + 40)
|
||||
BOOTROM_LOADTTY_LABEL_POSN = (BOOTROM_POSNX + 28, BOOTROM_POSNY + 40)
|
||||
BOOTROM_WRITABLE_POSN = (BOOTROM_POSNX + 125, BOOTROM_POSNY + 20)
|
||||
BOOTROM_WRITABLE_LABEL_POSN = (BOOTROM_POSNX + 148, BOOTROM_POSNY + 18)
|
||||
|
||||
SCREEN_BOOTROM_WRITABLE_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 125, BOOTROM_POSNY + 20)
|
||||
SCREEN_BOOTROM_LOADPTR_RADIO_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 5, BOOTROM_POSNY + 20)
|
||||
SCREEN_BOOTROM_LOADTTY_RADIO_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 5, BOOTROM_POSNY + 40)
|
||||
|
||||
|
||||
QUITBUTTON_POSN = (142, 930)
|
||||
HALTBUTTON_POSN = (14, 930)
|
||||
RUNBUTTON_POSN = HALTBUTTON_POSN
|
||||
SINGLESTEPBUTTON_POSN = (14, 890)
|
||||
|
||||
SCREEN_QUITBUTTON_POSN = (CANVAS_WIDTH + 142, 930)
|
||||
SCREEN_HALTBUTTON_POSN = (CANVAS_WIDTH + 14, 930)
|
||||
SCREEN_SINGLESTEPBUTTON_POSN = (CANVAS_WIDTH + 14, 890)
|
||||
|
||||
HALT_RECT = (SCREEN_HALTBUTTON_POSN, (100, 25))
|
||||
QUIT_RECT = (SCREEN_QUITBUTTON_POSN, (100, 25))
|
||||
SINGLESTEP_RECT = (SCREEN_SINGLESTEPBUTTON_POSN, (228, 25))
|
||||
ROM_WRITABLE_RECT = (SCREEN_BOOTROM_WRITABLE_POSN, (19, 19))
|
||||
LOADPTR_RADIO_RECT = (SCREEN_BOOTROM_LOADPTR_RADIO_POSN, (19, 19))
|
||||
LOADTTY_RADIO_RECT = (SCREEN_BOOTROM_LOADTTY_RADIO_POSN, (19, 19))
|
||||
|
||||
quit_rect = pygame.Rect(QUIT_RECT)
|
||||
halt_rect = pygame.Rect(HALT_RECT)
|
||||
singlestep_rect = pygame.Rect(SINGLESTEP_RECT)
|
||||
romwritable_rect = pygame.Rect(ROM_WRITABLE_RECT)
|
||||
loadptrradio_rect = pygame.Rect(LOADPTR_RADIO_RECT)
|
||||
loadttyradio_rect = pygame.Rect(LOADTTY_RADIO_RECT)
|
||||
ptrfilename_rect = pygame.Rect(PTR_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ptpfilename_rect = pygame.Rect(PTP_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ttyinfilename_rect = pygame.Rect(TTYIN_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ttyoutfilename_rect = pygame.Rect(TTYOUT_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
|
||||
font_data = pygame.font.Font(None, 21)
|
||||
font_label = pygame.font.Font(None, 24)
|
||||
|
||||
checkbox_on = pygame.image.load(os.path.join('images', 'checkon.png'))
|
||||
checkbox_off = pygame.image.load(os.path.join('images', 'checkoff.png'))
|
||||
radiobutton_on = pygame.image.load(os.path.join('images', 'radioon.png'))
|
||||
radiobutton_off = pygame.image.load(os.path.join('images', 'radiooff.png'))
|
||||
|
||||
class Menu:
|
||||
def __init__(self, itemlist, width):
|
||||
self.itemlist = itemlist
|
||||
self.numitems = len(itemlist)
|
||||
self.height = self.numitems * ITEM_HEIGHT # + ITEM_HEIGHT / 3
|
||||
self.width = width
|
||||
self.beforesurface = pygame.Surface((self.width, self.width))
|
||||
self.menusurface = pygame.Surface((self.width, self.height))
|
||||
self.menusurface.fill(BLACK)
|
||||
self.menusurface.fill(WHITE, ((1, 1), (self.width - 2, self.height - 2)))
|
||||
offset = 0
|
||||
for item in itemlist:
|
||||
self.menusurface.blit(font_data.render('%s' % item, 1, RED), (5, offset))
|
||||
offset += ITEM_HEIGHT
|
||||
|
||||
def show(self, display, posn):
|
||||
x, y = posn
|
||||
if (x > display.get_width() - self.width):
|
||||
newposn = (x - self.width, y)
|
||||
else:
|
||||
newposn = posn
|
||||
|
||||
menurect = pygame.Rect(newposn, (self.width, self.height))
|
||||
sourcerect = (newposn, (self.width, self.height))
|
||||
self.beforesurface.blit(display, (0, 0), sourcerect)
|
||||
display.blit(self.menusurface, newposn)
|
||||
pygame.display.flip()
|
||||
result = 0
|
||||
end_flag = 1
|
||||
while end_flag:
|
||||
pygame.event.pump()
|
||||
for event in pygame.event.get():
|
||||
if (event.type == MOUSEBUTTONUP):
|
||||
if (event.button == 1):
|
||||
if (menurect.collidepoint(event.pos)):
|
||||
display.blit(self.beforesurface, newposn)
|
||||
pygame.display.flip()
|
||||
x, y = newposn
|
||||
result = (event.pos[1] - y) / ITEM_HEIGHT + 1
|
||||
if (result > self.numitems):
|
||||
result = self.numitems
|
||||
end_flag = 0
|
||||
display.blit(self.beforesurface, newposn)
|
||||
pygame.display.flip()
|
||||
return result
|
||||
|
||||
|
||||
def draw_checkbox(surface, posn, on):
|
||||
if (on):
|
||||
surface.blit(checkbox_on, posn)
|
||||
else:
|
||||
surface.blit(checkbox_off, posn)
|
||||
|
||||
def draw_radiobutton(surface, posn, on):
|
||||
if (on):
|
||||
surface.blit(radiobutton_on, posn)
|
||||
else:
|
||||
surface.blit(radiobutton_off, posn)
|
||||
|
||||
def update_octalbox(surface, x, y, format, value):
|
||||
surface.blit(font_data.render(format % value, 1, BLACK), (x + BOX_DATA_OFFSETX, y + BOX_DATA_OFFSETY))
|
||||
|
||||
def draw_divider(surface, y, width):
|
||||
pygame.draw.line(surface, LIGHTGREY, (0, y), (width - 1, y))
|
||||
pygame.draw.line(surface, BLACK, (0, y+1), (width - 1, y+1))
|
||||
|
||||
def draw_databox(surface, label, x, y, width, height):
|
||||
if (len(label) > 0):
|
||||
surface.blit(font_label.render(label, 1, BLACK), (x, y + LABEL_OFFSETY))
|
||||
pygame.draw.rect(surface, BLACK, ((x, y), (width, height)), 1)
|
||||
surface.fill(WHITE, ((x + 1,y + 1),(width - 2,height - 2)))
|
||||
|
||||
def panel_init(panel, led_on, led_off, halt, quit, ss):
|
||||
panel.blit(font_label.render('pymlac 0.1', 1, BLACK), VERSION_POSN)
|
||||
|
||||
draw_databox(panel, 'ptr', BOX_POSNX, PTR_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ptp', BOX_POSNX, PTP_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ttyin', BOX_POSNX, TTYIN_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ttyout', BOX_POSNX, TTYOUT_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
|
||||
panel.blit(led_off, (LEDL_POSNX, LEDAC_POSNY))
|
||||
panel.blit(font_label.render('l', 1, BLACK), (LEDL_POSNX, LEDAC_POSNY + LEDAC_LABEL_OFFSETY))
|
||||
panel.blit(font_label.render('ac', 1, BLACK), (LEDAC_POSNX, LEDAC_POSNY + LEDAC_LABEL_OFFSETY))
|
||||
led_posnx = LEDAC_POSNX
|
||||
mark_count = 1
|
||||
for i in LED_BIT_RANGE:
|
||||
if (mark_count == 0):
|
||||
mark_count = 3
|
||||
pygame.draw.line(panel, GREY, (led_posnx - 1, LEDAC_POSNY + 10), (led_posnx - 1, LEDAC_POSNY + 15))
|
||||
panel.blit(led_off, (led_posnx, LEDAC_POSNY))
|
||||
led_posnx += LED_BIT_OFFSETX
|
||||
mark_count -= 1
|
||||
|
||||
draw_divider(panel, FILE_ROM_DIVIDER, PANEL_WIDTH)
|
||||
|
||||
panel.blit(font_label.render('pc', 1, BLACK), (LEDPC_POSNX, LEDPC_POSNY + LEDPC_LABEL_OFFSETY))
|
||||
led_posnx = LEDPC_POSNX
|
||||
mark_count = 1
|
||||
for i in LED_BIT_RANGE:
|
||||
if (mark_count == 0):
|
||||
mark_count = 3
|
||||
pygame.draw.line(panel, GREY, (led_posnx - 1, LEDPC_POSNY + 10), (led_posnx - 1, LEDPC_POSNY + 15))
|
||||
panel.blit(led_off, (led_posnx, LEDPC_POSNY))
|
||||
led_posnx += LED_BIT_OFFSETX
|
||||
mark_count -= 1
|
||||
|
||||
draw_divider(panel, ROM_MON_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_divider(panel, MON_LED_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_databox(panel, 'l', REGL_BOX_POSNX, REGL_BOX_POSNY, REGL_BOX_WIDTH, REGL_BOX_HEIGHT)
|
||||
draw_databox(panel, 'ac', REGAC_BOX_POSNX, REGAC_BOX_POSNY, REGAC_BOX_WIDTH, REGAC_BOX_HEIGHT)
|
||||
draw_databox(panel, 'pc', REGPC_BOX_POSNX, REGPC_BOX_POSNY, REGPC_BOX_WIDTH, REGPC_BOX_HEIGHT)
|
||||
|
||||
draw_databox(panel, 'dx', REGDX_BOX_POSNX, REGDX_BOX_POSNY, REGDX_BOX_WIDTH, REGDX_BOX_HEIGHT)
|
||||
draw_databox(panel, 'dpc', REGDPC_BOX_POSNX, REGDPC_BOX_POSNY, REGDPC_BOX_WIDTH, REGDPC_BOX_HEIGHT)
|
||||
draw_databox(panel, 'dy', REGDY_BOX_POSNX, REGDY_BOX_POSNY, REGDY_BOX_WIDTH, REGDY_BOX_HEIGHT)
|
||||
|
||||
draw_divider(panel, REGS_MON_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_divider(panel, BOX_BOT_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
panel.blit(font_label.render('boot rom:', 1, BLACK), BOOTROM_LABEL_POSN)
|
||||
draw_checkbox(panel, BOOTROM_WRITABLE_POSN, 0)
|
||||
panel.blit(font_label.render('is writable', 1, BLACK), BOOTROM_WRITABLE_LABEL_POSN)
|
||||
draw_radiobutton(panel, BOOTROM_LOADPTR_RADIO_POSN, 1)
|
||||
panel.blit(font_label.render('papertape', 1, BLACK), BOOTROM_LOADPTR_LABEL_POSN)
|
||||
draw_radiobutton(panel, BOOTROM_LOADTTY_RADIO_POSN, 0)
|
||||
panel.blit(font_label.render('teletype', 1, BLACK), BOOTROM_LOADTTY_LABEL_POSN)
|
||||
|
||||
panel.blit(quit, QUITBUTTON_POSN)
|
||||
panel.blit(halt, HALTBUTTON_POSN)
|
||||
panel.blit(ss, SINGLESTEPBUTTON_POSN)
|
||||
|
||||
|
||||
def draw_leds(screen, y, value, led_on, led_off):
|
||||
posn = LEDAC_SCREEN_POSNX
|
||||
for i in LED_BIT_RANGE:
|
||||
if (value & 1 << i):
|
||||
screen.blit(led_on, (posn, y))
|
||||
else:
|
||||
screen.blit(led_off, (posn, y))
|
||||
posn += LED_BIT_OFFSETX
|
||||
|
||||
# Open up a display, draw our loaded image onto it -- check for ESC; if pressed, exit...
|
||||
#
|
||||
def main():
|
||||
# Setup a 1280x1024 screen...
|
||||
screen = pygame.display.set_mode((1280,1024), HWSURFACE|DOUBLEBUF|FULLSCREEN)
|
||||
|
||||
# Make a "surface" which is the same size as our screen...
|
||||
background = pygame.Surface((1024,1024))
|
||||
|
||||
# Make this background surface a black colour (note: R,G,B tuple):
|
||||
background.fill((0,0,0))
|
||||
|
||||
# Load our images
|
||||
panel = pygame.image.load(os.path.join('images', 'panel.png'))
|
||||
led_off = pygame.image.load(os.path.join('images', 'led_off.png'))
|
||||
led_on = pygame.image.load(os.path.join('images', 'led_on.png'))
|
||||
quit_button = pygame.image.load(os.path.join('images', 'quit.png'))
|
||||
halt_button = pygame.image.load(os.path.join('images', 'halt.png'))
|
||||
run_button = pygame.image.load(os.path.join('images', 'run.png'))
|
||||
singlestep_button = pygame.image.load(os.path.join('images', 'singlestep.png'))
|
||||
|
||||
# Now define some constants
|
||||
# Set the Font ..
|
||||
on_label = font_data.render('ON', 1, (0,0,0))
|
||||
off_label = font_data.render('OFF', 1, (0,0,0))
|
||||
eof_label = font_data.render('EOF', 1, (255,0,0))
|
||||
file_name = font_data.render('default_game.ptp', 1, (0,0,0))
|
||||
file_name2 = font_data.render('DEFAULT_GAME_abcdefghijklmnopqrstuvwxyz.ptp', 1, (0,0,0))
|
||||
|
||||
panel_init(panel, led_on, led_off, halt_button, quit_button, singlestep_button)
|
||||
|
||||
screen.blit(background, (0,0))
|
||||
screen.blit(panel, (1024,0))
|
||||
|
||||
running = 1
|
||||
offset = 0
|
||||
one_step = 0
|
||||
full_screen = 1
|
||||
|
||||
rom_is_writable = 0
|
||||
load_from_ptr = 1
|
||||
|
||||
menu = Menu(DEVICEMENU, 85)
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
# Infinite loop to keep the window open until "QUIT" widget is pressed...
|
||||
while 1:
|
||||
clock.tick(120)
|
||||
pygame.event.pump()
|
||||
for event in pygame.event.get():
|
||||
# if (event.type == VIDEORESIZE):
|
||||
# print 'VIDEORESIZE'
|
||||
# screen.blit(background, (0,0))
|
||||
# pygame.display.flip()
|
||||
if (event.type == MOUSEBUTTONUP):
|
||||
if (event.button == 3):
|
||||
if (ptrfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ptpfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ttyinfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ttyoutfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
|
||||
# pygame.image.save(screen, snapshot_file)
|
||||
|
||||
# if (full_screen):
|
||||
# pygame.display.set_mode((100, 100))
|
||||
# else:
|
||||
# pygame.display.set_mode((1280,1024), HWSURFACE|DOUBLEBUF|FULLSCREEN)
|
||||
# full_screen = not full_screen
|
||||
if (romwritable_rect.collidepoint(event.pos)):
|
||||
if (rom_is_writable):
|
||||
screen.blit(checkbox_off, SCREEN_BOOTROM_WRITABLE_POSN)
|
||||
panel.blit(checkbox_off, BOOTROM_WRITABLE_POSN)
|
||||
pygame.display.flip()
|
||||
rom_is_writable = 0
|
||||
else:
|
||||
screen.blit(checkbox_on, SCREEN_BOOTROM_WRITABLE_POSN)
|
||||
panel.blit(checkbox_on, BOOTROM_WRITABLE_POSN)
|
||||
pygame.display.flip()
|
||||
rom_is_writable = 1
|
||||
if (loadptrradio_rect.collidepoint(event.pos)):
|
||||
if (not load_from_ptr):
|
||||
screen.blit(radiobutton_on, SCREEN_BOOTROM_LOADPTR_RADIO_POSN)
|
||||
panel.blit(radiobutton_on, BOOTROM_LOADPTR_RADIO_POSN)
|
||||
screen.blit(radiobutton_off, SCREEN_BOOTROM_LOADTTY_RADIO_POSN)
|
||||
panel.blit(radiobutton_off, BOOTROM_LOADTTY_RADIO_POSN)
|
||||
pygame.display.flip()
|
||||
load_from_ptr = 1
|
||||
if (loadttyradio_rect.collidepoint(event.pos)):
|
||||
if (load_from_ptr):
|
||||
screen.blit(radiobutton_off, SCREEN_BOOTROM_LOADPTR_RADIO_POSN)
|
||||
panel.blit(radiobutton_off, BOOTROM_LOADPTR_RADIO_POSN)
|
||||
screen.blit(radiobutton_on, SCREEN_BOOTROM_LOADTTY_RADIO_POSN)
|
||||
panel.blit(radiobutton_on, BOOTROM_LOADTTY_RADIO_POSN)
|
||||
pygame.display.flip()
|
||||
load_from_ptr = 0
|
||||
if (halt_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
screen.blit(halt_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(halt_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 1
|
||||
if (quit_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
sys.exit()
|
||||
if (singlestep_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
one_step = 1
|
||||
|
||||
if running or one_step:
|
||||
one_step = 0
|
||||
|
||||
# draw on 'screen'
|
||||
offset += 2
|
||||
if (offset >= CANVAS_WIDTH):
|
||||
offset = 0
|
||||
pygame.draw.line(background, YELLOW, (0,offset), (CANVAS_WIDTH - 1,offset))
|
||||
pygame.draw.line(background, YELLOW, (offset, 0), (offset, CANVAS_WIDTH - 1))
|
||||
pygame.draw.line(background, YELLOW, (0,CANVAS_WIDTH-offset), (CANVAS_WIDTH - 1,CANVAS_WIDTH-offset))
|
||||
pygame.draw.line(background, YELLOW, (CANVAS_WIDTH-offset, 0), (CANVAS_WIDTH-offset, CANVAS_WIDTH - 1))
|
||||
screen.blit(background, (0,0))
|
||||
|
||||
# draw on the 'control panel'
|
||||
screen.blit(panel, (CANVAS_WIDTH,0))
|
||||
draw_leds(screen, LEDAC_SCREEN_POSNY, offset, led_on, led_off)
|
||||
draw_leds(screen, LEDPC_SCREEN_POSNY, 0xffff - offset, led_on, led_off)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGL_BOX_POSNX, REGL_BOX_POSNY, '%1.1o', 0)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGAC_BOX_POSNX, REGAC_BOX_POSNY, '%6.6o', offset)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGPC_BOX_POSNX, REGPC_BOX_POSNY, '%6.6o', 0xffff - offset)
|
||||
screen.blit(off_label, PTR_OFF_POSN)
|
||||
screen.blit(eof_label, PTR_EOF_POSN)
|
||||
screen.blit(file_name, PTR_FILE_POSN)
|
||||
screen.blit(on_label, PTP_ON_POSN)
|
||||
screen.blit(eof_label, PTP_EOF_POSN)
|
||||
screen.blit(file_name, PTP_FILE_POSN)
|
||||
screen.blit(off_label, TTYIN_OFF_POSN)
|
||||
screen.blit(file_name, TTYIN_FILE_POSN)
|
||||
screen.blit(on_label, TTYOUT_ON_POSN)
|
||||
screen.blit(file_name2, TTYOUT_FILE_POSN)
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
background.fill(BLACK)
|
||||
pygame.quit()
|
||||
|
||||
# So we can run straight from the CLI...
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,545 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
########################################################################################################
|
||||
# For handling filenames...
|
||||
import os, time, sys
|
||||
|
||||
# The pygame module itself...
|
||||
import pygame
|
||||
|
||||
# The image handling...
|
||||
import pygame.image
|
||||
|
||||
# Important constant definitions for Pygame,
|
||||
# in this example: used to setup the "Double Buffered" Display...
|
||||
from pygame.locals import *
|
||||
|
||||
# Initialise SDL environment
|
||||
pygame.init()
|
||||
|
||||
# Get the image from: ./images/pygamelogo1.gif
|
||||
#panel_file = os.path.join('images', 'panel.png')
|
||||
#led_on_file = os.path.join('images', 'led_on.png')
|
||||
#led_off_file = os.path.join('images', 'led_off.png')
|
||||
|
||||
ITEM_HEIGHT = 17
|
||||
DEVICEMENU = ('Mount', 'Dismount', 'Rewind', 'Turn on', 'Turn off')
|
||||
|
||||
snapshot_file = 'pymlac_snap.bmp'
|
||||
|
||||
BLACK = (0,0,0)
|
||||
WHITE = (255,255,255)
|
||||
YELLOW = (255,255,64)
|
||||
GREY = (128,128,128)
|
||||
LIGHTGREY = (182,182,182)
|
||||
RED = (128, 0, 0)
|
||||
|
||||
VERSION_POSN = (173,0)
|
||||
|
||||
CANVAS_WIDTH = 1024
|
||||
CANVAS_HEIGHT = 1024
|
||||
|
||||
BOX_POSNX = 5
|
||||
BOX_POSNY = 45
|
||||
BOX_OFFSETY = 42
|
||||
BOX_WIDTH = 246
|
||||
BOX_HEIGHT = 20
|
||||
LABEL_OFFSETY = -19
|
||||
EOF_OFFSETX = CANVAS_WIDTH + BOX_POSNX + 180
|
||||
TAGS_OFFSETY = -17
|
||||
ON_OFFSETX = 1254
|
||||
OFF_OFFSETX = 1247
|
||||
FILE_OFSETX = 1032
|
||||
FILE_OFFSETY = +1
|
||||
|
||||
PTR_BOX_POSNY = BOX_POSNY
|
||||
PTR_LABEL_POSN = (BOX_POSNX, PTR_BOX_POSNY + LABEL_OFFSETY)
|
||||
PTR_EOF_POSN = (EOF_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_ON_POSN = (ON_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_OFF_POSN = (OFF_OFFSETX, PTR_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTR_FILE_POSN = (FILE_OFSETX, PTR_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
PTP_BOX_POSNY = PTR_BOX_POSNY + BOX_OFFSETY
|
||||
PTP_LABEL_POSN = (BOX_POSNX, PTP_BOX_POSNY + LABEL_OFFSETY)
|
||||
PTP_EOF_POSN = (EOF_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_ON_POSN = (ON_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_OFF_POSN = (OFF_OFFSETX, PTP_BOX_POSNY + TAGS_OFFSETY)
|
||||
PTP_FILE_POSN = (FILE_OFSETX, PTP_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
TTYIN_BOX_POSNY = PTP_BOX_POSNY + BOX_OFFSETY
|
||||
TTYIN_LABEL_POSN = (BOX_POSNX, TTYIN_BOX_POSNY + LABEL_OFFSETY)
|
||||
TTYIN_EOF_POSN = (EOF_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_ON_POSN = (ON_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_OFF_POSN = (OFF_OFFSETX, TTYIN_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYIN_FILE_POSN = (FILE_OFSETX, TTYIN_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
TTYOUT_BOX_POSNY = TTYIN_BOX_POSNY + BOX_OFFSETY
|
||||
TTYOUT_LABEL_POSN = (BOX_POSNX, TTYOUT_BOX_POSNY + LABEL_OFFSETY)
|
||||
TTYOUT_EOF_POSN = (EOF_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_ON_POSN = (ON_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_OFF_POSN = (OFF_OFFSETX, TTYOUT_BOX_POSNY + TAGS_OFFSETY)
|
||||
TTYOUT_FILE_POSN = (FILE_OFSETX, TTYOUT_BOX_POSNY + FILE_OFFSETY)
|
||||
|
||||
LEDAC_LABEL_OFFSETY = -18
|
||||
LEDL_POSNX = 0
|
||||
LEDAC_POSNX = 17
|
||||
LEDAC_POSNY = 715
|
||||
LEDPC_LABEL_OFFSETY = -18
|
||||
LEDPC_POSNX = 17
|
||||
LEDPC_POSNY = LEDAC_POSNY + 35
|
||||
LED_BIT_OFFSETX = 15
|
||||
LED_BIT_RANGE = (15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
|
||||
LEDL_SCREEN_POSNX = CANVAS_WIDTH + LEDL_POSNX
|
||||
LEDAC_SCREEN_POSNX = CANVAS_WIDTH + LEDAC_POSNX
|
||||
LEDAC_SCREEN_POSNY = LEDAC_POSNY
|
||||
|
||||
LEDPC_SCREEN_POSNX = CANVAS_WIDTH + LEDPC_POSNX
|
||||
LEDPC_SCREEN_POSNY = LEDPC_POSNY
|
||||
|
||||
PANEL_WIDTH = 256
|
||||
|
||||
REGS_MON_DIVIDERY = 205
|
||||
ROM_MON_DIVIDERY = 325
|
||||
FILE_ROM_DIVIDER = 690
|
||||
MON_LED_DIVIDERY = 775
|
||||
BOX_BOT_DIVIDERY = 875
|
||||
|
||||
BOX_POSNY = 802
|
||||
|
||||
REGL_BOX_POSNX = 73
|
||||
REGL_BOX_POSNY = BOX_POSNY
|
||||
REGL_BOX_WIDTH = 15
|
||||
REGL_BOX_HEIGHT = 20
|
||||
|
||||
REGAC_BOX_POSNX = 95
|
||||
REGAC_BOX_POSNY = REGL_BOX_POSNY
|
||||
REGAC_BOX_WIDTH = 55
|
||||
REGAC_BOX_HEIGHT = 20
|
||||
|
||||
REGPC_BOX_POSNX = 170
|
||||
REGPC_BOX_POSNY = REGL_BOX_POSNY
|
||||
REGPC_BOX_WIDTH = 55
|
||||
REGPC_BOX_HEIGHT = 20
|
||||
|
||||
REGDX_BOX_POSNX = 33
|
||||
REGDX_BOX_POSNY = BOX_POSNY + 40
|
||||
REGDX_BOX_WIDTH = 55
|
||||
REGDX_BOX_HEIGHT = 20
|
||||
|
||||
REGDY_BOX_POSNX = 95
|
||||
REGDY_BOX_POSNY = REGDX_BOX_POSNY
|
||||
REGDY_BOX_WIDTH = 55
|
||||
REGDY_BOX_HEIGHT = 20
|
||||
|
||||
REGDPC_BOX_POSNX = 170
|
||||
REGDPC_BOX_POSNY = REGDX_BOX_POSNY
|
||||
REGDPC_BOX_WIDTH = 55
|
||||
REGDPC_BOX_HEIGHT = 20
|
||||
|
||||
BOX_DATA_OFFSETX = 4
|
||||
BOX_DATA_OFFSETY = 2
|
||||
|
||||
BOOTROM_POSNX = 20
|
||||
BOOTROM_POSNY = 215
|
||||
|
||||
BOOTROM_LABEL_POSN = (BOOTROM_POSNX, BOOTROM_POSNY)
|
||||
BOOTROM_WRITABLE_POSN = (BOOTROM_POSNX + 5, BOOTROM_POSNY + 20)
|
||||
BOOTROM_WRITABLE_LABEL_POSN = (BOOTROM_POSNX + 28, BOOTROM_POSNY + 18)
|
||||
BOOTROM_LOAD_POSN = (BOOTROM_POSNX, BOOTROM_POSNY + 40)
|
||||
BOOTROM_LOADPTR_RADIO_POSN = (BOOTROM_POSNX + 5, BOOTROM_POSNY + 60)
|
||||
BOOTROM_LOADPTR_LABEL_POSN = (BOOTROM_POSNX + 28, BOOTROM_POSNY + 58)
|
||||
BOOTROM_LOADTTY_RADIO_POSN = (BOOTROM_POSNX + 5, BOOTROM_POSNY + 80)
|
||||
BOOTROM_LOADTTY_LABEL_POSN = (BOOTROM_POSNX + 28, BOOTROM_POSNY + 80)
|
||||
|
||||
SCREEN_BOOTROM_WRITABLE_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 5, BOOTROM_POSNY + 20)
|
||||
SCREEN_BOOTROM_LOADPTR_RADIO_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 5, BOOTROM_POSNY + 60)
|
||||
SCREEN_BOOTROM_LOADTTY_RADIO_POSN = (CANVAS_WIDTH + BOOTROM_POSNX + 5, BOOTROM_POSNY + 80)
|
||||
|
||||
|
||||
QUITBUTTON_POSN = (142, 930)
|
||||
HALTBUTTON_POSN = (14, 930)
|
||||
RUNBUTTON_POSN = HALTBUTTON_POSN
|
||||
SINGLESTEPBUTTON_POSN = (14, 890)
|
||||
|
||||
SCREEN_QUITBUTTON_POSN = (CANVAS_WIDTH + 142, 930)
|
||||
SCREEN_HALTBUTTON_POSN = (CANVAS_WIDTH + 14, 930)
|
||||
SCREEN_SINGLESTEPBUTTON_POSN = (CANVAS_WIDTH + 14, 890)
|
||||
|
||||
HALT_RECT = (SCREEN_HALTBUTTON_POSN, (100, 25))
|
||||
QUIT_RECT = (SCREEN_QUITBUTTON_POSN, (100, 25))
|
||||
SINGLESTEP_RECT = (SCREEN_SINGLESTEPBUTTON_POSN, (228, 25))
|
||||
ROM_WRITABLE_RECT = (SCREEN_BOOTROM_WRITABLE_POSN, (19, 19))
|
||||
LOADPTR_RADIO_RECT = (SCREEN_BOOTROM_LOADPTR_RADIO_POSN, (19, 19))
|
||||
LOADTTY_RADIO_RECT = (SCREEN_BOOTROM_LOADTTY_RADIO_POSN, (19, 19))
|
||||
|
||||
quit_rect = pygame.Rect(QUIT_RECT)
|
||||
halt_rect = pygame.Rect(HALT_RECT)
|
||||
singlestep_rect = pygame.Rect(SINGLESTEP_RECT)
|
||||
romwritable_rect = pygame.Rect(ROM_WRITABLE_RECT)
|
||||
loadptrradio_rect = pygame.Rect(LOADPTR_RADIO_RECT)
|
||||
loadttyradio_rect = pygame.Rect(LOADTTY_RADIO_RECT)
|
||||
ptrfilename_rect = pygame.Rect(PTR_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ptpfilename_rect = pygame.Rect(PTP_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ttyinfilename_rect = pygame.Rect(TTYIN_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
ttyoutfilename_rect = pygame.Rect(TTYOUT_FILE_POSN, (BOX_WIDTH, BOX_HEIGHT))
|
||||
|
||||
font_data = pygame.font.Font(None, 21)
|
||||
font_label = pygame.font.Font(None, 24)
|
||||
|
||||
checkbox_on = pygame.image.load(os.path.join('images', 'checkon.png'))
|
||||
checkbox_off = pygame.image.load(os.path.join('images', 'checkoff.png'))
|
||||
radiobutton_on = pygame.image.load(os.path.join('images', 'radioon.png'))
|
||||
radiobutton_off = pygame.image.load(os.path.join('images', 'radiooff.png'))
|
||||
|
||||
class Menu:
|
||||
def __init__(self, itemlist, width):
|
||||
self.itemlist = itemlist
|
||||
self.numitems = len(itemlist)
|
||||
self.height = self.numitems * ITEM_HEIGHT # + ITEM_HEIGHT / 3
|
||||
self.width = width
|
||||
self.beforesurface = pygame.Surface((self.width, self.width))
|
||||
self.menusurface = pygame.Surface((self.width, self.height))
|
||||
self.menusurface.fill(BLACK)
|
||||
self.menusurface.fill(WHITE, ((1, 1), (self.width - 2, self.height - 2)))
|
||||
offset = 0
|
||||
for item in itemlist:
|
||||
self.menusurface.blit(font_data.render('%s' % item, 1, RED), (5, offset))
|
||||
offset += ITEM_HEIGHT
|
||||
|
||||
def show(self, display, posn):
|
||||
x, y = posn
|
||||
if (x > display.get_width() - self.width):
|
||||
newposn = (x - self.width, y)
|
||||
else:
|
||||
newposn = posn
|
||||
|
||||
menurect = pygame.Rect(newposn, (self.width, self.height))
|
||||
sourcerect = (newposn, (self.width, self.height))
|
||||
self.beforesurface.blit(display, (0, 0), sourcerect)
|
||||
display.blit(self.menusurface, newposn)
|
||||
pygame.display.flip()
|
||||
result = 0
|
||||
end_flag = 1
|
||||
while end_flag:
|
||||
pygame.event.pump()
|
||||
for event in pygame.event.get():
|
||||
if (event.type == MOUSEBUTTONUP):
|
||||
if (event.button == 1):
|
||||
if (menurect.collidepoint(event.pos)):
|
||||
display.blit(self.beforesurface, newposn)
|
||||
pygame.display.flip()
|
||||
x, y = newposn
|
||||
result = (event.pos[1] - y) / ITEM_HEIGHT + 1
|
||||
if (result > self.numitems):
|
||||
result = self.numitems
|
||||
end_flag = 0
|
||||
display.blit(self.beforesurface, newposn)
|
||||
pygame.display.flip()
|
||||
return result
|
||||
|
||||
|
||||
def draw_checkbox(surface, posn, on):
|
||||
if (on):
|
||||
surface.blit(checkbox_on, posn)
|
||||
else:
|
||||
surface.blit(checkbox_off, posn)
|
||||
|
||||
def draw_radiobutton(surface, posn, on):
|
||||
if (on):
|
||||
surface.blit(radiobutton_on, posn)
|
||||
else:
|
||||
surface.blit(radiobutton_off, posn)
|
||||
|
||||
def update_octalbox(surface, x, y, format, value):
|
||||
surface.blit(font_data.render(format % value, 1, BLACK), (x + BOX_DATA_OFFSETX, y + BOX_DATA_OFFSETY))
|
||||
|
||||
def draw_divider(surface, y, width):
|
||||
pygame.draw.line(surface, LIGHTGREY, (0, y), (width - 1, y))
|
||||
pygame.draw.line(surface, BLACK, (0, y+1), (width - 1, y+1))
|
||||
|
||||
def draw_databox(surface, label, x, y, width, height):
|
||||
if (len(label) > 0):
|
||||
surface.blit(font_label.render(label, 1, BLACK), (x, y + LABEL_OFFSETY))
|
||||
pygame.draw.rect(surface, BLACK, ((x, y), (width, height)), 1)
|
||||
surface.fill(WHITE, ((x + 1,y + 1),(width - 2,height - 2)))
|
||||
|
||||
def panel_init(panel, led_on, led_off, halt, quit, ss):
|
||||
panel.blit(font_label.render('pymlac 0.1', 1, BLACK), VERSION_POSN)
|
||||
|
||||
draw_databox(panel, 'ptr', BOX_POSNX, PTR_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ptp', BOX_POSNX, PTP_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ttyin', BOX_POSNX, TTYIN_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
draw_databox(panel, 'ttyout', BOX_POSNX, TTYOUT_BOX_POSNY, BOX_WIDTH, BOX_HEIGHT)
|
||||
|
||||
panel.blit(led_off, (LEDL_POSNX, LEDAC_POSNY))
|
||||
panel.blit(font_label.render('l', 1, BLACK), (LEDL_POSNX, LEDAC_POSNY + LEDAC_LABEL_OFFSETY))
|
||||
panel.blit(font_label.render('ac', 1, BLACK), (LEDAC_POSNX, LEDAC_POSNY + LEDAC_LABEL_OFFSETY))
|
||||
led_posnx = LEDAC_POSNX
|
||||
mark_count = 1
|
||||
for i in LED_BIT_RANGE:
|
||||
if (mark_count == 0):
|
||||
mark_count = 3
|
||||
pygame.draw.line(panel, GREY, (led_posnx - 1, LEDAC_POSNY + 10), (led_posnx - 1, LEDAC_POSNY + 15))
|
||||
panel.blit(led_off, (led_posnx, LEDAC_POSNY))
|
||||
led_posnx += LED_BIT_OFFSETX
|
||||
mark_count -= 1
|
||||
|
||||
draw_divider(panel, FILE_ROM_DIVIDER, PANEL_WIDTH)
|
||||
|
||||
panel.blit(font_label.render('pc', 1, BLACK), (LEDPC_POSNX, LEDPC_POSNY + LEDPC_LABEL_OFFSETY))
|
||||
led_posnx = LEDPC_POSNX
|
||||
mark_count = 1
|
||||
for i in LED_BIT_RANGE:
|
||||
if (mark_count == 0):
|
||||
mark_count = 3
|
||||
pygame.draw.line(panel, GREY, (led_posnx - 1, LEDPC_POSNY + 10), (led_posnx - 1, LEDPC_POSNY + 15))
|
||||
panel.blit(led_off, (led_posnx, LEDPC_POSNY))
|
||||
led_posnx += LED_BIT_OFFSETX
|
||||
mark_count -= 1
|
||||
|
||||
draw_divider(panel, ROM_MON_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_divider(panel, MON_LED_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_databox(panel, 'l', REGL_BOX_POSNX, REGL_BOX_POSNY, REGL_BOX_WIDTH, REGL_BOX_HEIGHT)
|
||||
draw_databox(panel, 'ac', REGAC_BOX_POSNX, REGAC_BOX_POSNY, REGAC_BOX_WIDTH, REGAC_BOX_HEIGHT)
|
||||
draw_databox(panel, 'pc', REGPC_BOX_POSNX, REGPC_BOX_POSNY, REGPC_BOX_WIDTH, REGPC_BOX_HEIGHT)
|
||||
|
||||
draw_databox(panel, 'dx', REGDX_BOX_POSNX, REGDX_BOX_POSNY, REGDX_BOX_WIDTH, REGDX_BOX_HEIGHT)
|
||||
draw_databox(panel, 'dpc', REGDPC_BOX_POSNX, REGDPC_BOX_POSNY, REGDPC_BOX_WIDTH, REGDPC_BOX_HEIGHT)
|
||||
draw_databox(panel, 'dy', REGDY_BOX_POSNX, REGDY_BOX_POSNY, REGDY_BOX_WIDTH, REGDY_BOX_HEIGHT)
|
||||
|
||||
draw_divider(panel, REGS_MON_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
draw_divider(panel, BOX_BOT_DIVIDERY, PANEL_WIDTH)
|
||||
|
||||
panel.blit(font_label.render('boot rom:', 1, BLACK), BOOTROM_LABEL_POSN)
|
||||
draw_checkbox(panel, BOOTROM_WRITABLE_POSN, 0)
|
||||
panel.blit(font_label.render('is writable', 1, BLACK), BOOTROM_WRITABLE_LABEL_POSN)
|
||||
panel.blit(font_label.render('load from:', 1, BLACK), BOOTROM_LOAD_POSN)
|
||||
draw_radiobutton(panel, BOOTROM_LOADPTR_RADIO_POSN, 1)
|
||||
panel.blit(font_label.render('papertape', 1, BLACK), BOOTROM_LOADPTR_LABEL_POSN)
|
||||
draw_radiobutton(panel, BOOTROM_LOADTTY_RADIO_POSN, 0)
|
||||
panel.blit(font_label.render('teletype', 1, BLACK), BOOTROM_LOADTTY_LABEL_POSN)
|
||||
|
||||
panel.blit(quit, QUITBUTTON_POSN)
|
||||
panel.blit(halt, HALTBUTTON_POSN)
|
||||
panel.blit(ss, SINGLESTEPBUTTON_POSN)
|
||||
|
||||
|
||||
def draw_leds(screen, y, value, led_on, led_off):
|
||||
posn = LEDAC_SCREEN_POSNX
|
||||
for i in LED_BIT_RANGE:
|
||||
if (value & 1 << i):
|
||||
screen.blit(led_on, (posn, y))
|
||||
else:
|
||||
screen.blit(led_off, (posn, y))
|
||||
posn += LED_BIT_OFFSETX
|
||||
|
||||
# Open up a display, draw our loaded image onto it -- check for ESC; if pressed, exit...
|
||||
#
|
||||
def main():
|
||||
# Setup a 1280x1024 screen...
|
||||
screen = pygame.display.set_mode((1280,1024), HWSURFACE|DOUBLEBUF|FULLSCREEN)
|
||||
|
||||
# Make a "surface" which is the same size as our screen...
|
||||
background = pygame.Surface((1024,1024))
|
||||
|
||||
# Make this background surface a black colour (note: R,G,B tuple):
|
||||
background.fill((0,0,0))
|
||||
|
||||
# Load our images
|
||||
panel = pygame.image.load(os.path.join('images', 'panel.png'))
|
||||
led_off = pygame.image.load(os.path.join('images', 'led_off.png'))
|
||||
led_on = pygame.image.load(os.path.join('images', 'led_on.png'))
|
||||
quit_button = pygame.image.load(os.path.join('images', 'quit.png'))
|
||||
halt_button = pygame.image.load(os.path.join('images', 'halt.png'))
|
||||
run_button = pygame.image.load(os.path.join('images', 'run.png'))
|
||||
singlestep_button = pygame.image.load(os.path.join('images', 'singlestep.png'))
|
||||
|
||||
# Now define some constants
|
||||
# Set the Font ..
|
||||
on_label = font_data.render('ON', 1, (0,0,0))
|
||||
off_label = font_data.render('OFF', 1, (0,0,0))
|
||||
eof_label = font_data.render('EOF', 1, (255,0,0))
|
||||
file_name = font_data.render('default_game.ptp', 1, (0,0,0))
|
||||
file_name2 = font_data.render('DEFAULT_GAME_abcdefghijklmnopqrstuvwxyz.ptp', 1, (0,0,0))
|
||||
|
||||
panel_init(panel, led_on, led_off, halt_button, quit_button, singlestep_button)
|
||||
|
||||
screen.blit(background, (0,0))
|
||||
screen.blit(panel, (1024,0))
|
||||
|
||||
running = 1
|
||||
offset = 0
|
||||
one_step = 0
|
||||
full_screen = 1
|
||||
|
||||
rom_is_writable = 0
|
||||
load_from_ptr = 1
|
||||
|
||||
menu = Menu(DEVICEMENU, 85)
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
# Infinite loop to keep the window open until "QUIT" widget is pressed...
|
||||
while 1:
|
||||
clock.tick(120)
|
||||
pygame.event.pump()
|
||||
for event in pygame.event.get():
|
||||
# if (event.type == VIDEORESIZE):
|
||||
# print 'VIDEORESIZE'
|
||||
# screen.blit(background, (0,0))
|
||||
# pygame.display.flip()
|
||||
if (event.type == MOUSEBUTTONUP):
|
||||
if (event.button == 3):
|
||||
if (ptrfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ptpfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ttyinfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
if (ttyoutfilename_rect.collidepoint(event.pos)):
|
||||
menuitem = menu.show(screen, event.pos)
|
||||
if menuitem == 1:
|
||||
pass # do MOUNT
|
||||
elif menuitem == 2:
|
||||
pass # do DISMOUNT
|
||||
elif menuitem == 3:
|
||||
pass # do REWIND
|
||||
elif menuitem == 4:
|
||||
pass # do MOTOR ON
|
||||
elif menuitem == 5:
|
||||
pass # do MOTOR OFF
|
||||
|
||||
# pygame.image.save(screen, snapshot_file)
|
||||
|
||||
# if (full_screen):
|
||||
# pygame.display.set_mode((100, 100))
|
||||
# else:
|
||||
# pygame.display.set_mode((1280,1024), HWSURFACE|DOUBLEBUF|FULLSCREEN)
|
||||
# full_screen = not full_screen
|
||||
if (romwritable_rect.collidepoint(event.pos)):
|
||||
if (rom_is_writable):
|
||||
screen.blit(checkbox_off, SCREEN_BOOTROM_WRITABLE_POSN)
|
||||
panel.blit(checkbox_off, BOOTROM_WRITABLE_POSN)
|
||||
pygame.display.flip()
|
||||
rom_is_writable = 0
|
||||
else:
|
||||
screen.blit(checkbox_on, SCREEN_BOOTROM_WRITABLE_POSN)
|
||||
panel.blit(checkbox_on, BOOTROM_WRITABLE_POSN)
|
||||
pygame.display.flip()
|
||||
rom_is_writable = 1
|
||||
if (loadptrradio_rect.collidepoint(event.pos)):
|
||||
if (not load_from_ptr):
|
||||
screen.blit(radiobutton_on, SCREEN_BOOTROM_LOADPTR_RADIO_POSN)
|
||||
panel.blit(radiobutton_on, BOOTROM_LOADPTR_RADIO_POSN)
|
||||
screen.blit(radiobutton_off, SCREEN_BOOTROM_LOADTTY_RADIO_POSN)
|
||||
panel.blit(radiobutton_off, BOOTROM_LOADTTY_RADIO_POSN)
|
||||
pygame.display.flip()
|
||||
load_from_ptr = 1
|
||||
if (loadttyradio_rect.collidepoint(event.pos)):
|
||||
if (load_from_ptr):
|
||||
screen.blit(radiobutton_off, SCREEN_BOOTROM_LOADPTR_RADIO_POSN)
|
||||
panel.blit(radiobutton_off, BOOTROM_LOADPTR_RADIO_POSN)
|
||||
screen.blit(radiobutton_on, SCREEN_BOOTROM_LOADTTY_RADIO_POSN)
|
||||
panel.blit(radiobutton_on, BOOTROM_LOADTTY_RADIO_POSN)
|
||||
pygame.display.flip()
|
||||
load_from_ptr = 0
|
||||
if (halt_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
screen.blit(halt_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(halt_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 1
|
||||
if (quit_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
sys.exit()
|
||||
if (singlestep_rect.collidepoint(event.pos)):
|
||||
if (running):
|
||||
screen.blit(run_button, SCREEN_HALTBUTTON_POSN)
|
||||
panel.blit(run_button, HALTBUTTON_POSN)
|
||||
pygame.display.flip()
|
||||
running = 0
|
||||
else:
|
||||
one_step = 1
|
||||
|
||||
if running or one_step:
|
||||
one_step = 0
|
||||
|
||||
# draw on 'screen'
|
||||
offset += 2
|
||||
if (offset >= CANVAS_WIDTH):
|
||||
offset = 0
|
||||
pygame.draw.line(background, YELLOW, (0,offset), (CANVAS_WIDTH - 1,offset))
|
||||
pygame.draw.line(background, YELLOW, (offset, 0), (offset, CANVAS_WIDTH - 1))
|
||||
pygame.draw.line(background, YELLOW, (0,CANVAS_WIDTH-offset), (CANVAS_WIDTH - 1,CANVAS_WIDTH-offset))
|
||||
pygame.draw.line(background, YELLOW, (CANVAS_WIDTH-offset, 0), (CANVAS_WIDTH-offset, CANVAS_WIDTH - 1))
|
||||
screen.blit(background, (0,0))
|
||||
|
||||
# draw on the 'control panel'
|
||||
screen.blit(panel, (CANVAS_WIDTH,0))
|
||||
draw_leds(screen, LEDAC_SCREEN_POSNY, offset, led_on, led_off)
|
||||
draw_leds(screen, LEDPC_SCREEN_POSNY, 0xffff - offset, led_on, led_off)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGL_BOX_POSNX, REGL_BOX_POSNY, '%1.1o', 0)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGAC_BOX_POSNX, REGAC_BOX_POSNY, '%6.6o', offset)
|
||||
update_octalbox(screen, CANVAS_WIDTH + REGPC_BOX_POSNX, REGPC_BOX_POSNY, '%6.6o', 0xffff - offset)
|
||||
screen.blit(off_label, PTR_OFF_POSN)
|
||||
screen.blit(eof_label, PTR_EOF_POSN)
|
||||
screen.blit(file_name, PTR_FILE_POSN)
|
||||
screen.blit(on_label, PTP_ON_POSN)
|
||||
screen.blit(eof_label, PTP_EOF_POSN)
|
||||
screen.blit(file_name, PTP_FILE_POSN)
|
||||
screen.blit(off_label, TTYIN_OFF_POSN)
|
||||
screen.blit(file_name, TTYIN_FILE_POSN)
|
||||
screen.blit(on_label, TTYOUT_ON_POSN)
|
||||
screen.blit(file_name2, TTYOUT_FILE_POSN)
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
background.fill(BLACK)
|
||||
pygame.quit()
|
||||
|
||||
# So we can run straight from the CLI...
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#from Globals import *
|
||||
import Test1
|
||||
|
||||
class Test2(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def alpha(self):
|
||||
global instruction_cycles
|
||||
instruction_cycles += 1
|
||||
|
||||
global instruction_cycles
|
||||
|
||||
instruction_cycles = 1
|
||||
|
||||
test1 = Test1.Test1()
|
||||
|
||||
print 'Before test1.alpha(), instruction_cycles =', instruction_cycles
|
||||
|
||||
test1.alpha()
|
||||
|
||||
print 'After test1.alpha(), instruction_cycles =', instruction_cycles
|
||||
|
||||
test2 = Test2()
|
||||
|
||||
test2.alpha()
|
||||
|
||||
print 'After test2.alpha(), instruction_cycles =', instruction_cycles
|
||||
@@ -1 +0,0 @@
|
||||
../images
|
||||
@@ -1,280 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
A cute 3D starfield effect.
|
||||
My first experiment with PyGame, and the most Python I've ever written!
|
||||
There's plenty of room for further optimization here, thats left as an exercise for the reader ;)
|
||||
Will McGugan - will@willmcgugan.com
|
||||
http://www.willmcgugan.com
|
||||
"""
|
||||
|
||||
__copyright__ = "2005 Will McGugan"
|
||||
__version__ = "1.0"
|
||||
__license__ = "Public Domain"
|
||||
__author__ = "Will McGugan"
|
||||
|
||||
import random, math, pygame
|
||||
from pygame.locals import *
|
||||
|
||||
|
||||
try:
|
||||
import psyco
|
||||
psyco.full()
|
||||
except ImportError:
|
||||
print "This demo runs much smoother with the 'Psyco' module"
|
||||
print "You can get it from http://psyco.sourceforge.net/"
|
||||
|
||||
def DegreesToRadians( degrees ):
|
||||
"Converts an angle from degrees to radians."
|
||||
return degrees * ( math.pi / 180. )
|
||||
|
||||
# Look ma, globals!
|
||||
# Some values you can fiddle with...
|
||||
|
||||
# Size of the window
|
||||
# Actualy looks better in lo-res with chuncky pixels! (Try it in fullscreen)
|
||||
SCREEN_WIDTH= 800 # 640
|
||||
SCREEN_HEIGHT= 600 # 480
|
||||
# 1 for fullscreen, 0 for windowed
|
||||
FULLSCREEN_MODE= 1
|
||||
# Stars per Z unit
|
||||
STAR_DENSITY= 1
|
||||
# Distance of far plane
|
||||
STAR_DISTANCE= 4000.
|
||||
# Field of view
|
||||
FOV= DegreesToRadians( 90. )
|
||||
# Rotation speed of camera
|
||||
ROTATION_SPEED= DegreesToRadians( 40. )
|
||||
# Speed of camera
|
||||
SPEED= 2000.
|
||||
# Use wu-pixels (anti-aliased points)
|
||||
WU_PIXELS= 0
|
||||
|
||||
class Star( object ):
|
||||
"A 'star' here is just a point in 3D space."
|
||||
|
||||
def __init__( self, x, y, z ):
|
||||
"Initialise a star at point x, y, z"
|
||||
self.x, self.y, self.z = x, y, z
|
||||
|
||||
|
||||
def render( self, surface, x, y, bright ):
|
||||
"""Renders a star of brightness 'bright' at x, y.
|
||||
Uses 'wu-pixel' algorithm derived from http://freespace.virgin.net/hugo.elias/graphics/x_wupixl.htm
|
||||
Basically it draws a point at fractional coordinates."""
|
||||
|
||||
if not WU_PIXELS:
|
||||
b= int( min( 255., bright * 255. ) )
|
||||
surface.set_at( ( int(x), int(y) ), ( b, b, b ) )
|
||||
return
|
||||
|
||||
if x >= 0. and x < SCREEN_WIDTH and y >= 0. and y < SCREEN_HEIGHT:
|
||||
# Get the fractional, and the whole part of the coordinates
|
||||
fx, ix = math.modf( x )
|
||||
fy, iy = math.modf( y )
|
||||
ix = int(ix)
|
||||
iy = int(iy)
|
||||
|
||||
# Scale brightness (a value between 0 and 1), to a colour value (0-255)
|
||||
bright= min( bright*255., 255. )
|
||||
|
||||
# Calculate the brightness of each sub pixel, see the link above
|
||||
btl = int( (1.-fx) * (1.-fy) * bright )
|
||||
btr = int( fx * (1.-fy) * bright )
|
||||
bbl = int( (1.-fx)* fy * bright )
|
||||
bbr = int( fx * fy * bright )
|
||||
|
||||
# Plot the pixel on screen
|
||||
surface.set_at( ( ix, iy ), ( btl, btl, btl ) )
|
||||
surface.set_at( ( ix+1, iy ), ( btr, btr, btr ) )
|
||||
surface.set_at( ( ix, iy+1 ), ( bbl, bbl, bbl ) )
|
||||
surface.set_at( ( ix+1, iy+1 ), ( bbr, bbr, bbr ) )
|
||||
|
||||
|
||||
class Starfield( object ):
|
||||
"Stores and renders starfield"
|
||||
|
||||
def __init__( self, density = 1. ):
|
||||
"Density is in stars per unit of z"
|
||||
|
||||
self.density = density
|
||||
|
||||
# List of stars
|
||||
self.stars = []
|
||||
|
||||
# The point in the distance where we have generated new stars
|
||||
self.generated_z = 0
|
||||
|
||||
|
||||
def render( self, surface, fov, angle, position_z, distance ):
|
||||
"Renders all the stars."
|
||||
|
||||
# Screen dimensions
|
||||
view_width = float( SCREEN_WIDTH )
|
||||
view_height = float( SCREEN_HEIGHT )
|
||||
|
||||
# Aspect ratio of screen
|
||||
aspect = view_width / view_height
|
||||
|
||||
# Calculate the distance where 3D units equal screen units
|
||||
view_distance = ( view_width / 2. ) / math.tan( fov / 2. )
|
||||
|
||||
# Calculate the maximum exents of projected pixels
|
||||
far_width = math.tan( fov / 2. ) * distance * 2.;
|
||||
far_height = far_width / aspect
|
||||
max_diameter = math.sqrt( far_width * far_width + far_height * far_height )
|
||||
|
||||
# This is the radius of a cone that the camera would fit inside
|
||||
# Its used to cull stars that are no longer potentialy visible
|
||||
screen_radius= math.sqrt( view_width * view_width + view_height * view_height ) / 2.
|
||||
|
||||
# Generate new stars in the distance, untill we have at least enough stars to render a screen-full
|
||||
generate_distance = 10
|
||||
while self.generated_z < position_z + distance:
|
||||
self.add_stars( self.generated_z, max_diameter, max_diameter, generate_distance )
|
||||
self.generated_z += generate_distance
|
||||
|
||||
# clear screen
|
||||
background_colour = 0, 0, 0
|
||||
surface.fill( background_colour )
|
||||
|
||||
# Adjustment required to put stars in the centre of the screen
|
||||
centre_x = view_width / 2.
|
||||
centre_y = view_height / 2.
|
||||
|
||||
# Precalculate 1 over distance, because it is generally quicker to multiply by 1/x that it is to divide by x
|
||||
oodistance = 1. / distance
|
||||
|
||||
# Create a list of all the stars which are currently visible, or could become visible
|
||||
visible_stars = []
|
||||
|
||||
# Multiply brightness by constant scale so they are clearer
|
||||
bright_scale = 1.5
|
||||
|
||||
# Precalculate sin and cos of the angle
|
||||
sin_angle= math.sin( angle )
|
||||
cos_angle= math.cos( angle )
|
||||
|
||||
# Project ( transform 3D to 2D ) and render all stars
|
||||
for star in self.stars:
|
||||
remove_star = False
|
||||
star_z= star.z - position_z
|
||||
# If the star is in front of the camera...
|
||||
if star.z > position_z + .1:
|
||||
# If it is within the visible z range...
|
||||
if star.z <= position_z + distance:
|
||||
# Precalculate 1 over z
|
||||
oostar_z = 1. / star_z
|
||||
|
||||
screen_x = star.x * cos_angle - star.y * sin_angle
|
||||
screen_y = star.x * sin_angle + star.y * cos_angle
|
||||
|
||||
screen_x *= view_distance * oostar_z
|
||||
screen_y *= view_distance * oostar_z
|
||||
|
||||
# If the star is within the camera cone...
|
||||
if math.fabs( screen_x ) < screen_radius and math.fabs( screen_y ) < screen_radius:
|
||||
star_z_over_distance= star_z * oodistance
|
||||
# Calculate a brightness value so the stars fade in, rather than pop in
|
||||
bright = ( 1. - star_z_over_distance * star_z_over_distance ) * bright_scale
|
||||
star.render( surface, screen_x + centre_x, screen_y + centre_y, bright )
|
||||
else:
|
||||
# The star is out of the potentialy visible cone in front of the camera
|
||||
remove_star = True
|
||||
else:
|
||||
# The star as behind the camera, and will not be seen again
|
||||
remove_star = True
|
||||
|
||||
if not remove_star:
|
||||
visible_stars.append( star )
|
||||
|
||||
# Replace star list with only visible stars, so we dont continue to process any stars no longer visible
|
||||
self.stars = visible_stars
|
||||
|
||||
|
||||
def add_stars( self, z, width, height, distance ):
|
||||
"Add random stars in to the distance."
|
||||
new_star_count = int( distance * self.density )
|
||||
centre_x = width / 2.
|
||||
centre_y = height / 2.
|
||||
for _ in xrange( new_star_count ):
|
||||
new_star = Star( random.random() * width - centre_x,
|
||||
random.random() * height - centre_y,
|
||||
z + random.random() * distance )
|
||||
self.stars.append( new_star )
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
print "3D stars effect"
|
||||
print "Will McGugan will@willmcgugan.com"
|
||||
print "Try my game - Ping Ball (http://www.pingball.com )"
|
||||
print ""
|
||||
print "Move the mouse left and right to change rotation, up and down to change speed"
|
||||
print "Press (W) to toggle wu-pixels"
|
||||
|
||||
random.seed()
|
||||
pygame.init()
|
||||
|
||||
screen_dimensions= SCREEN_WIDTH, SCREEN_HEIGHT
|
||||
|
||||
if FULLSCREEN_MODE:
|
||||
screen = pygame.display.set_mode( screen_dimensions, FULLSCREEN )
|
||||
pygame.mouse.set_visible( False )
|
||||
else:
|
||||
screen = pygame.display.set_mode( screen_dimensions )
|
||||
|
||||
pygame.display.set_caption( '3D Stars Example' )
|
||||
|
||||
backbuffer= pygame.Surface( screen_dimensions, SWSURFACE, screen )
|
||||
|
||||
# Camera z
|
||||
# For this example x will be the width of the screen, y will be the height, and z will be 'in' the screen
|
||||
cam_z= 0.
|
||||
|
||||
# Camera angle
|
||||
angle= 0.
|
||||
|
||||
# Create a clock so we can position the camera correctly
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
# Create our starfield
|
||||
starfield = Starfield( STAR_DENSITY )
|
||||
|
||||
# So we can toggle wu-pixels
|
||||
global WU_PIXELS
|
||||
|
||||
done= 0
|
||||
while not done:
|
||||
|
||||
# Calculate the speed and rotation speed based on current mouse position
|
||||
mouse_x, mouse_y = pygame.mouse.get_pos()
|
||||
half_width = float( SCREEN_WIDTH ) / 2.
|
||||
rotation_speed = ROTATION_SPEED * ( float( mouse_x ) - half_width ) / half_width ;
|
||||
camera_speed = SPEED * float( SCREEN_HEIGHT - mouse_y ) / float( SCREEN_HEIGHT )
|
||||
|
||||
# Move the 'camera' forward, using the time and speed to calculate its position
|
||||
time_passed = clock.tick() / 1000.
|
||||
angle += time_passed * rotation_speed
|
||||
cam_z += time_passed * camera_speed
|
||||
|
||||
# Lock the display, render the stars
|
||||
screen.lock()
|
||||
starfield.render( screen, FOV, angle, cam_z, STAR_DISTANCE )
|
||||
screen.unlock()
|
||||
|
||||
# Flip next frame
|
||||
pygame.display.flip()
|
||||
|
||||
# Process events
|
||||
for e in pygame.event.get():
|
||||
if e.type == QUIT or (e.type == KEYUP and e.key == K_ESCAPE):
|
||||
done = 1
|
||||
break
|
||||
elif e.type == KEYUP and e.key == K_w:
|
||||
WU_PIXELS = (1,0)[WU_PIXELS]
|
||||
print "Wu-pixels", ("off","on")[WU_PIXELS]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#from wxPython.wx import *
|
||||
import wx
|
||||
|
||||
application = wx.PySimpleApp()
|
||||
|
||||
dialog = wx.Frame ( None, wx.ID_ANY, 'Title Here.' )
|
||||
|
||||
dialog.Show ( True )
|
||||
|
||||
application.MainLoop()
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import Test
|
||||
|
||||
def main():
|
||||
test = Test.Test()
|
||||
|
||||
test.testit()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
ABC
|
||||
XYZ.
|
||||
Reference in New Issue
Block a user