Jump to content
IGNORED

DSRLINK Code Tutorial


TheBF

Recommended Posts

3 hours ago, GDMike said:

are we talking about this? ahh, maybe you didnt notice, i erased most of everything so i can start over.

I did notice you erased part of it, to start over. But you kept the wrong PAB.

And, of course, if you do improvements you don't show, then there's no way to help you to get further.

  • Like 1
Link to comment
Share on other sites

****************************************
* FILEM -  FILE MANAGAMENT  06/04/20   *
*                                      *
*  LAST UPDATE: 11/01/20               *
*                                      *
****************************************
TLOAD  TEXT 'LOAD DSK  '
 
***
*
* SAVE DSK FILE
*
***
* ENTRY IS DSRS FOR SAVE ROUTINE
 
 
GFERR1 B    @GFERR
DSRS   LI   R0,929
       LI   R2,>0001
       LI   R3,>3000     * "0"
       BLWP @VSBR        * 1ST WE NEED TO GET THE LENGTH OF THE FILENAME IN R2
       CB   R1,R3        * ERROR! CANT BE "0 OR LESS"
       JLE  GFERR1       * DISPLAY A MESSAGE
       LI   R3,>3900     * IT HAS TO BE A NUMBER
       CB   R1,R3
       JGT  GFERR1       * ERROR, NOT 1-9
       LI   R3,>2E00     * NOW ITS LEGAL, CONTINUE LOOKIN SG FOR "." PERIOD MARK
       INC  R0
       INC  R2           * R2=2
       BLWP @VSBR
       CB   R1,R3
       JNE  GFERR1       * NOT VALID! ERROR GOTTA HAVE "."
       INC  R0
       INC  R2           * R2=3
       LI   R3,>4100     * LOOKING FOR A CHAR VALUE UPPER A-Z
       BLWP @VSBR
       CB   R1,R3
       JLT  GFERR1       * NOPE NOT A-Z, ERROR- WAS LESS THAN "A"
       LI   R3,>5A00     * CHECK FOR GREATER THAN "Z"
       CB   R1,R3
       JGT  GFERR1       * NOPE, NOT A-Z, WAS GREATER THAN "Z"
       LI   R3,>2000     * CHECK FOR SPACE TO GET TOTAL COUNT
KLNMH  INC  R0
       INC  R2
       BLWP @VSBR
       CB   R1,R3        * FOUND END OF NAME YET?, NO, KEEP LOOKING
       JNE  KLNMH        * KEEP LOOKING FOR NAME HERE
       AI   R2,2         * WE ADD IN THE "DSK" 2 BYTES TO GET OUR FULL DESCRIP #
       MOV  R2,@COUNT    * SAVE THE LENGTH OF FILENAME
       LI   R0,926
       LI   R1,FLNM      * FILENAME BUFFER
       BLWP @VMBR
 
       LI   R0,0
       LI   R1,FLNM
       BLWP @VMBW
       LI   R0,120
       LI   R1,>2000     * CLEAR SCREEN AREA
CSVA   BLWP @VSBW
       INC  R0
       CI   R0,960
       JLT  CSVA
       BL   @BEEP
       LI   R0,320       * MESSAGE "SAVING..."
       LI   R1,SVMG
       LI   R2,12
       BLWP @VMBW
       LI   R0,333
       LI   R1,FLNM
       MOV  @COUNT,R2
       BLWP @VMBW
 
* the preceding code put something like
* DSK2.UHOH into "FLNM"
* with 9 in "COUNT" IF we are here, then
* the user already created the filename.
* the filename is echoed on that last
* piece of code.
 
* this next section sets up our data
* INFO: SNPS1 - SNPS4 CONTAIN 860 BYTES
* EACH OF DATA. BUT BANK# DECIDES WHICH
* BANK TO MAKE ACTIVE.
 
 
* 1ST TIME USE IS SET ABOVE, BUT WHEN
* WE LOOP, WE WANT TO HAVE CODE FOR ALL
* PAGES, BUT WE NEED TO PAD THE REST OF
* THE BANK WITH SPACES " " TO FULLFILL
* THE FOLLOWING IS JUST A PRE-SET
 
       CLR  @PAGE
       MOV  R4,@PAGE     * SET EVERYTHING
       MOV  R4,@RECONT   * CLEAR RECORD COUNTER
       LI   R1,>1100     * TO LOW CRAM
       MOV  R1,@BANK#
       LI   R12,>1E00
       SBO  0
       LI   R3,>4006
       MOV  R1,*R3
       SBZ  0
 
* GATHER CORRECT BANK # & PAGE HERE
* GET READY TO RUMBLE!
 
 
SPRCS  MOV  @PAGE,R4
       INC  R4
       MOV  R4,@PAGE
       CI   R4,4
       JGT  NXBK         * PAGE REACHED MAX, SO WE INCR BANK#
       CI   R4,1
       JGT  NXP2
       LI   R1,S32P1
       JMP  NXC
NXP2   CI   R4,2
       JGT  NXP3
       LI   R1,S32P2
       JMP  NXC
NXP3   CI   R4,3
       JGT  NXP4
       LI   R1,S32P3
       JMP  NXC          * AND SET PAGE TO 1 AGAIN
NXP4   LI   R1,S32P4
 
       LI   R0,SBUFF
       LI   R2,860       * MOV A PAGE
       BLWP @VMBW        * TO BUFFER
       LI   R0,SBUFF1
       LI   R1,PADD
       LI   R2,28        * PADD THE BALANCE
       BLWP @VMBW
 
       INC  RECONT       * RECORD COUNTER
HERE   INC  @PAGE        * AND PUSH ANOTHER 1000 BYTES FROM HERE!
       B    @SPRCS
 
 
NXBK   MOV  @BANK#,R1
       AI   R1,>0100
       MOV  R1,@BANK#
       CI   R1,>F000     * MAX 240!
       JGT  NXEX         * EXIT!
       LI   R12,>1E00
       SBO  0
       LI   R3,>4006
       MOV  R1,*R3
       SBZ  0
       CLR  @PAGE
       JMP  SPRCS        * GO AGAIN!
 
* AND EXIT
NXEX   LI   R4,>0001
       MOV  R4,@PAGE     * SET PAGE TO 1
       LI   R1,>1100     * SET BANK# TO 1 OF 245!
       MOV  R1,@BANK#
       LI   R12,>1E00
       SBO  0
       LI   R3,>4006     * THIS RESTORES SAMS
       MOV  R1,*R3       * TO PAGE 1
       SBZ  0
 
FEXITH BL   @PSTPG       * FILE EXIT HERE
       BL   @CCREST      * THIS RESTORES THE SCREEN
       LI   R0,120
       MOV  R0,@POS
       B    @CRTN
 
 
* GFERR ERROR! AND RESTORE SCREEN AND HONK
 
GFERR  BL   @HONK
       LI   R0,920
       LI   R1,TER1
       LI   R2,40
       BLWP @VMBW
GFERS  CLR  @>837C
       CLR  @>8375
       LIMI 2
       LIMI 0
       BLWP @KSCAN
       MOVB @>837C,R0
       JEQ  GFERS
GFEXIT BL   @CCREST
       LI   R0,120
       MOV  R0,@POS
       CLR  @COUNTP
       B    @CRTN
 
***
*
* OLD DSK.FILE
*
***
 
DSRL   LI   R0,533
       LI   R1,TLOAD
       LI   R2,10
       BLWP @VMBW
       B    @DSRL
 
***
*
* VARIABLES AND BUFFERS
***
*
* SAVE FILE PAB INFORMATION DV 80 FORMAT
*
***
SBUFF  EQU  >1000             * BUFFER ADDRESS
SBUFF1 EQU  >1FE4             * PADDED WITH 28 SPACES
PBAD   EQU  >79E              * PAB ADDRESS
FSPAB  DATA >0002,SBUFF,>8000,>0000,>0009
*             OP DV     128
EVEN
FLNM   BSS  48
COUNTP BYTE 0
STATUS EQU  >837C
POINT  EQU  >8356
READP  BYTE >02
WRITE  BYTE >03
CLOSP  BYTE >01
EOFP   DATA 0
ERRM   TEXT '* I/O ERROR * '
CPUBF  BSS  120
PADD   TEXT '                        '
RECONT DATA 0
 
TER1   TEXT '* INVALID DISK NUMBER * - PRESS ANY KEY '
SVMG   TEXT 'SAVING FILE:'
 
 
 
***
*
* USED FOR TRACING, DEBUGGING
*
***
 
TRACE  LI   R0,0
       LI   R1,>2A00
       BLWP @VSBW
TRASP  LIMI 2
       LIMI 0
       JMP  TRASP
 
 
DSR    MOV  R11,@SAVRTN
       LI   R6,FSPAB+9
       BLWP @DSRLNK
       DATA 8
       JEQ  DSRERP
       MOV  @SAVRTN,R11
       RT
 
DSRERP INC  @EOF
       LI   R0,PBAD+1
       BLWP @VSBR
       SRL  R1,13
       CI   R1,5
       JNE  IOERP
       RT
 
IOERP  AI   R1,>30
       SLA  R1,8
       LI   R0,288
       LI   R1,ERRM
       LI   R2,14
       BLWP @VMBW
 
EOJP   MOV  @EOF,@EOF
       JNE  NCLOSP
       MOVB @CLOSP,R1
       LI   R0,PBAD
       BLWP @VSBW
       BL   @DSR
NCLOSP DECT @RETURN
       MOV  @RETURN,R11
       RT

ive got my code here that places my first 1028 bytes of data into the CRAM >1000.

And it will keep moving that data as it increments forward to bank 240.

That label is "HERE"

The label"SPRCS" is where the loop begins. 

I just need to setup the DSRLNK prior to SPRCS and using "RECONT" to track the 128 byte records being written.

Of course I'm still missing the DSRLNK code, I figured, if I get this process into play, maybe it would make the DSRLNK code a little simpler to insert.

I've only placed code I know about. 

Thank you in advance.

 

 

Link to comment
Share on other sites

1 hour ago, GDMike said:

INC RECONT * RECORD COUNTER HERE INC @PAGE * AND PUSH ANOTHER 1000 BYTES FROM HERE! B @SPRCS

Oops, I'll have to revisit the "INC @PAGE" here because SPRCS does this for me.

And my PADD TEXT is 24 bytes. I've got to make it 28.

Sorry for those typos.

 

Edited by GDMike
Link to comment
Share on other sites

41 minutes ago, GDMike said:

I'll review"DSRLNK" and how to setup the PAB and related but I'm still not sure how

Just 128 bytes get written out of a block of vram containing 1028 bytes of data then I have to make sure that another 128 bytes get written again and so on before filling the buffer again.

You need to update the buffer address in the PAB every time you write a new record.

  • Like 1
Link to comment
Share on other sites

I've got my nose buried in the e/a book.

And I've come to the conclusion of my PAB from what I gather.

FSPAB DATA >0012, SBUFF, >8000, >0000, >0030

This is supposed to be a Display Variable 128 OUTPUT file that is set for "OPEN" for create.

I'm now reading up on my creation of my "PBAD", (PAB ADDRESS.).

So I have an understanding.

Sorry, ? with me.

Edited by GDMike
Link to comment
Share on other sites

You should have taken a closer look at the pseudo code I gave you.

There's no point in having a buffer in VDP RAM that's larger than the record size. There's no point in moving a thousand bytes over to VDP RAM, then store them chunk by chunk. Instead, you move only 128 bytes (max) to you buffer, and write one record. Then you move another 128 bytes (max), to the same buffer, and store that in a new record. You do this in a loop, which stores one screen/page/bank, or whatever you call it. Then you make an outer loop that advances to the next screen/page/bank, until you have run out of banks.

 

Your PAB definition still doesn't look like the one I suggested. It's still wrong, as in not functional.

 

You move data to and from @COUNT in a few places, but it's not defined.

  • Like 1
Link to comment
Share on other sites

14 minutes ago, apersson850 said:

You should have taken a closer look at the pseudo code I gave you.

There's no point in having a buffer in VDP RAM that's larger than the record size. There's no point in moving a thousand bytes over to VDP RAM, then store them chunk by chunk. Instead, you move only 128 bytes (max) to you buffer, and write one record. Then you move another 128 bytes (max), to the same buffer, and store that in a new record. You do this in a loop, which stores one screen/page/bank, or whatever you call it. Then you make an outer loop that advances to the next screen/page/bank, until you have run out of banks.

I can handle changing the code to do this.

I just need to know what is wrong with the FSPAB layout.

Link to comment
Share on other sites

14 minutes ago, GDMike said:

Ohhh...hmmm

 

DO NOT GO THERE!—unless you fancy writing your own DSRLNK. The E/A DSRLNK expects >8356 to point to the filename length byte. DSRLNK uses that to parse the filename (read, “full pathname”) to pick out the devicename, like “DSK2”, (which is part of the filename!) to then search the DSR for that devicename. When DSRLNK calls the found devicename routine in the DSR, it has already positioned the PAB pointer to the proper spot the DSR routine needs. You do not position it anywhere but pointing at byte 9 of the PAB in VRAM just before you call DSRLNK.

 

...lee

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...