A86: A beteer way to get a dump from romDump86


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

A86: A beteer way to get a dump from romDump86



OK, I know I had a lot of problems getting a communications program to

get a rom dump from my calc.  So I had to end up writing this (it's in

QBasic, shun, shun).  So the code is as follows and it's prety self

explainitory, hope it helps someone.  Sorry, I included the source, shun
shun.



   -Gen_Witt

     Gen_Witt@Aloradus.com
' RomCapture86 v0.1a {romCaptr.bas}
' (C) 1997 StrongWaters Gaming
'
' Press 'F5' to begin
'
'   I would like to thank Randy Gluvna (Gluvna@home.com) for his romDump86
' program.  However, I could not get Commo to recive a correct dump from the
' calculator, that is what this program is for.  A copy of romDump86 may be
' found at www.ticalc.org.
'
' You may freely distribute romCapture as long as IT IS NOT MODIFIED IN ANY
' FORM, AND THE COPYRIGHTS AND CREDITS REMAINED INTACT.  You are free to use
' the source code herein as long as due credit is given where due credit is
' due.  Me or any member of StrongWaters Gaming is not responsable for any
' dammage this program causes.

' ---== Declare ==---
DECLARE SUB makeWindow (xp AS INTEGER, yp AS INTEGER, xs AS INTEGER, ys AS INTEGER, tt AS STRING)
DECLARE SUB startUp ()
DECLARE FUNCTION spinner! (lx AS INTEGER, ly AS INTEGER, poss AS STRING)
DECLARE SUB mainMenu ()
DECLARE SUB drawHeader ()
DECLARE SUB singlePage ()
DECLARE SUB exiti ()
DECLARE SUB entireRom ()
' ---== TypeDef ==---
' ---== Const ==---
' ---== Dim ==---
' ---== Main ==---

DO
    startUp
    mainMenu
LOOP

SUB drawHeader
    COLOR 15, 1
    CLS
    COLOR 0, 7
    PRINT "                              RomCapture86 v0.1a                                "
    COLOR 7, 1: LOCATE 3
    PRINT "(C)1997 Strong Waters Gaming"
    LOCATE 25: COLOR , 3
    PRINT "                                                                                ";
END SUB

SUB entireRom
    ' ---== Dim ==---
    DIM comport AS INTEGER
    DIM rompage AS STRING
    DIM i AS INTEGER
    DIM j AS INTEGER

    ' ---== Settings ==---
    COLOR 7, 0
    makeWindow 19, 11, 30, 3, "Capture Entire ROM"
    LOCATE 12, 22
  
    PRINT "Com Port (1-4) ? [ ]"
    comport = spinner(40, 12, "1234")
    LOCATE 12, 22
 
    ' ---== Confrimation ==---
    COLOR 1, 7
    makeWindow 30, 19, 46, 3, "Confirm"
    COLOR 4
    LOCATE 19, 34
    PRINT "Make sure your calculator is connected"
    LOCATE 20, 40: PRINT "connected to the computer."
    COLOR 1: LOCATE 21, 45: PRINT "Continue ? [ ]"
    IF spinner(57, 21, "YN") = 2 THEN EXIT SUB
 

    ' ---== Prepare for transphere ==---
    CLOSE
    OPEN "COM" + LTRIM$(STR$(comport)) + ":9600,N,8,1,BIN" FOR RANDOM AS #1
    OPEN "entire.rom" FOR OUTPUT AS #2
    PRINT #2, "This is a faulty dump, an error has occured try again"
    CLOSE #2
    OPEN "entire.rom" FOR BINARY AS #2
    DO
        IF LOC(1) <> 0 THEN t$ = INPUT$(1, 1)
    LOOP UNTIL LOC(1) = 0
    t$ = ""

    ' ---== recive window ==---
    COLOR 1, 7
    makeWindow 30, 19, 46, 3, "Reciving..."
    COLOR 1: LOCATE 20, 36: PRINT "Press [ESC] to abort"
    COLOR 0: LOCATE 21, 36: PRINT "[       Begin Transmition        ]"
  
    DO
    LOOP UNTIL LOC(1) <> 0 OR INKEY$ = CHR$(27)
    COLOR 0: LOCATE 21, 36: PRINT "[11111111111111111111111111111111]"
    LOCATE 21, 37: COLOR 14
   
    ' ---== recive rom ==---
    DO
        IF LOC(1) <> 0 THEN
            s = LOC(1)
            ts = ts + s
            t$ = INPUT$(s, 1)
            PUT #2, , t$

            IF ts MOD 8192 = 0 AND ts <= 262144 THEN PRINT "[";
            ti = TIMER
        END IF
    LOOP UNTIL INKEY$ = CHR$(27) OR ti + 3 < TIMER
    CLOSE
  
    ' ---== test rom ==---
    IF ts <> 262144 THEN
        COLOR 15, 4
        makeWindow 15, 12, 50, 3, "Error"
        LOCATE 12, 17
        PRINT "File size is incorect.  You should try again."
        LOCATE 13, 17: PRINT "Recived size :"; ts; "bytes."
        LOCATE 14, 32: PRINT "<Press any key>"
        DO
        LOOP UNTIL INKEY$ <> ""
    ELSE
        COLOR 0: LOCATE 21, 36: PRINT "[         Splitting ROM          ]"
        OPEN "entire.rom" FOR BINARY LOCK READ AS #1
        FOR i = 1 TO 16
            rompage = MID$("0123456789ABCDEF", i, 1)
            OPEN "page_" + rompage + ".rom" FOR OUTPUT AS #2
            PRINT #2, "This is a faulty dump"
            CLOSE #2
            OPEN "page_" + rompage + ".rom" FOR BINARY AS #2
            FOR j = 1 TO 16
                s$ = SPACE$(1024)
                GET 1, , s$
                PUT 2, , s$
            NEXT j
            CLOSE #2
        NEXT i
        CLOSE #1
    END IF
END SUB

SUB exiti
    COLOR 7, 0
    CLS
    PRINT "Thank you for using RomCapture86"
    PRINT
    SYSTEM
END SUB

SUB mainMenu
    COLOR 1, 7
    makeWindow 3, 8, 38, 6, "Main Menu"
    LOCATE 9, 5
    PRINT "(P) Capture a single rom page"
    LOCATE , 5: PRINT "(R) Capture the entire rom"
    LOCATE , 5: PRINT "(X) Exit"
    PRINT
    LOCATE , 10: PRINT "Your choice ? [ ]"

    SELECT CASE spinner(25, 13, "PRX")
        CASE 1
            singlePage
        CASE 2
            entireRom
        CASE 3
            exiti
    END SELECT
END SUB

' SUB makeWindow
'   Draws an ASCII window at the specified cordinates wit a given title.
' xp, yp - the position of the upper left corner of the window
' xs, ys - the width and height of the window
' tt - the actual text of the title
'
SUB makeWindow (xp AS INTEGER, yp AS INTEGER, xs AS INTEGER, ys AS INTEGER, tt AS STRING)
    ' ---== Const ==---
    CONST winParts = "IM;:H<5F"
   
    ' ---== Dim ==---
    DIM i AS INTEGER ' For counter
    DIM ws AS STRING ' White space

    ' ---== Draw Window ==---
    LOCATE yp - 1, xp - 1
    PRINT MID$(winParts, 1, 1);
    FOR i = 1 TO xs
        PRINT MID$(winParts, 2, 1);
    NEXT i
    PRINT MID$(winParts, 3, 1);
   
    ws = MID$(winParts, 4, 1) + SPACE$(xs) + MID$(winParts, 4, 1)
    PRINT
    FOR i = 1 TO ys
        LOCATE , xp - 1
        PRINT ws
    NEXT i

    LOCATE , xp - 1
    PRINT MID$(winParts, 5, 1);
    FOR i = 1 TO xs
        PRINT MID$(winParts, 2, 1);
    NEXT i
    PRINT MID$(winParts, 6, 1);

    ' ---== Draw Title ==---
    LOCATE yp - 1, xp
    PRINT MID$(winParts, 7, 1) + tt + MID$(winParts, 8, 1);

    LOCATE yp, xp

END SUB

SUB singlePage
    ' ---== Dim ==---
    DIM comport AS INTEGER
    DIM rompage AS STRING

    ' ---== Settings ==---
    COLOR 7, 0
    makeWindow 18, 11, 30, 4, "Capture Single Page"
    LOCATE 12, 22
   
    PRINT "Com Port (1-4) ? [ ]"
    comport = spinner(40, 12, "1234")
    LOCATE 13, 22
   
    PRINT "Page (0-F)     ? [ ]"
    rompage = MID$("0123456789ABCDEF", spinner(40, 13, "0123456789ABCDEF"), 1)
    LOCATE 14, 22
   
    ' ---== Confrimation ==---
    COLOR 1, 7
    makeWindow 30, 19, 46, 3, "Confirm"
    COLOR 4
    LOCATE 19, 34
    PRINT "Make sure your calculator is connected"
    LOCATE 20, 40: PRINT "connected to the computer."
    COLOR 1: LOCATE 21, 45: PRINT "Continue ? [ ]"
    IF spinner(57, 21, "YN") = 2 THEN EXIT SUB
  

    ' ---== Prepare for transphere ==---
    CLOSE
    OPEN "COM" + LTRIM$(STR$(comport)) + ":9600,N,8,1,BIN" FOR RANDOM AS #1
    OPEN "page_" + rompage + ".rom" FOR OUTPUT AS #2
    PRINT #2, "This is a faulty dump"
    CLOSE #2
    OPEN "page_" + rompage + ".rom" FOR BINARY AS #2
    DO
        IF LOC(1) <> 0 THEN t$ = INPUT$(1, 1)
    LOOP UNTIL LOC(1) = 0
    t$ = ""

    ' ---== recive window ==---
    COLOR 1, 7
    makeWindow 30, 19, 46, 3, "Reciving..."
    COLOR 1: LOCATE 20, 36: PRINT "Press [ESC] to abort"
    COLOR 0: LOCATE 21, 36: PRINT "[       Begin Transmition        ]"
   
    DO
    LOOP UNTIL LOC(1) <> 0 OR INKEY$ = CHR$(27)
    COLOR 0: LOCATE 21, 36: PRINT "[11111111111111111111111111111111]"
    LOCATE 21, 37: COLOR 14
    
    ' ---== recive rom ==---
    DO
        IF LOC(1) <> 0 THEN
            s = LOC(1)
            ts = ts + s
            t$ = INPUT$(s, 1)
            PUT #2, , t$

            IF ts MOD 512 = 0 AND ts <= 16384 THEN PRINT "[";
            ti = TIMER
        END IF
    LOOP UNTIL INKEY$ = CHR$(27) OR ti + 3 < TIMER
    CLOSE
   
    ' ---== test rom ==---
    IF ts <> 16384 THEN
        COLOR 15, 4
        makeWindow 15, 12, 50, 3, "Error"
        LOCATE 12, 17
        PRINT "File size is incorect.  You should try again."
        LOCATE 13, 17: PRINT "Recived size :"; ts; "bytes."
        LOCATE 14, 32: PRINT "<Press any key>"
        DO
        LOOP UNTIL INKEY$ <> ""
    END IF
END SUB

FUNCTION spinner (lx AS INTEGER, ly AS INTEGER, poss AS STRING)
    CONST spin = "-\|/"
  
    DO
        i = i + 1
        LOCATE ly, lx
        SELECT CASE i
            CASE 1 TO 3
                PRINT MID$(spin, i, 1);
            CASE 4
                i = 0
                PRINT "/";
        END SELECT
        t = TIMER + .1
        DO
        LOOP UNTIL t < TIMER
        t$ = UCASE$(INKEY$)
        FOR j = 1 TO LEN(poss)
            IF t$ = MID$(poss, j, 1) THEN oks = -1
        NEXT j
    LOOP UNTIL oks

    LOCATE ly, lx: PRINT t$;

    FOR j = 1 TO LEN(poss)
        IF t$ = MID$(poss, j, 1) THEN i = j
    NEXT j
  
    spinner = i

END FUNCTION

SUB startUp
    drawHeader
END SUB