[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some Code to Look At



Below is the code that writes the contents of the Mark IV Memory card to a 
disk file.

When running, the Mark IV prom code writes images in the following order:

High byte of V image
Low byte of V image
High byte of I image
Low byte of I image

It repeats the above 2043 * 2037 times to get two complete images.  There 
are 2043 pixels across the frame, and 2037 frame lines.

To read out the data, the Memory card is reset, then an INP(&H301) fetches 
one byte in the order in which they were written. Note that nothing is 
sacred about the Memory card use of 300 and 301 in the I/O space.  These 
are used by the game card, and most Mark IV users will not be playing games 
while taking data.  ;^)  Jumpers allow a wide range of I/O addresses.

To write this to the disk, I define line containing 2043 16 bit integers 
with a QBasic TYPE statement.  I then write a Random access file that 
contains lines 1 to 2037.  This is done for both the V and I images.

It is quite possible for those of you that are clever than I at writing 
code can improve on the speed of the QBasic code.  It is also possible that

SHELL foo.exe

Where foo.exe is assembly code that does the big part of the work below 
will do the job.

Note eventually one has to worry about how to get the right names on the 
file that has been written.  Shell allows passing arguments, so I think 
this can also be solved.  So code just has to be written to replace the 
code between the ***************  below.  The print statement is just used 
to indicate that the data being collected is  reasonable.  It can be 
omitted, or you can find some other way to pass back to the QB program some 
sample data near the center of the frame.

I hope someone is interested in working on this.  I can add more comments, 
or interact with anyone who wants to have some code writing fun.

Tom Droege

Code below:


SaveIt1:
FileNumber = FileNumber + 1
LOCATE 1, 1
filenamea$ = "HV" + "01S11W" + "." + Sub$ + RIGHT$(STR$(FileNumber), 2)
filenameb$ = "HI" + "01S11W" + "." + Sub$ + RIGHT$(STR$(FileNumber), 2)
OPEN filenamea$ FOR RANDOM AS #3 LEN = LEN(OutBufa)
OPEN filenameb$ FOR RANDOM AS #4 LEN = LEN(OutBufb)
OPEN "LogFile" FOR APPEND AS #5
GOSUB LogEntry
CLOSE #5
GOSUB ReadReset

'***********************************************************
FOR lv% = 0 TO 2036

FOR li% = 0 TO 2042
a1& = INP(&H301)
a2% = INP(&H301)
IF a1& > 127 THEN
element% = -65536 + 256 * a1& + a2%
ELSE
element% = 256 * a1& + a2%
END IF

OutBufa.LineDataa(li%) = element%

'GOSUB OneWord
a1& = INP(&H301)
a2% = INP(&H301)
IF a1& > 127 THEN
element% = -65536 + 256 * a1& + a2%
ELSE
element% = 256 * a1& + a2%
END IF

OutBufb.LineDatab(li%) = element%

IF li% > 500 AND li% < 530 AND lv% = 1000 THEN
PRINT li%, a1&, a2%, element%
END IF

NEXT li%

PUT #3, lv% + 1, OutBufa

PUT #4, lv% + 1, OutBufb

NEXT lv%
CLOSE #3
CLOSE #4
'****************************************************************
SOUND 400, 2
LOCATE 40, 1
'PRINT "File Set Saved"
RETURN