6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:55 pm

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Apr 02, 2014 7:13 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I am fascinated by computer graphic algorithms based on integers. Forgive the self-indulgence, this will be a pic/code/video heavy thread based on the mild success of the Parallel Video Board system that is outputting 1920x1080 video @60Hz with 65K colors. It is highly programmable and it's not finished yet but it is outputting some neat stuff which I'd like to show off here.

Did I mention I like math? Specifically geometry and less so trigonometry. I had a great 6th grade geometry teacher. Things clicked in my brain back then which I remember to this day. Also things I remember from plotting graphics in Atari 800 BASIC over 20 years ago which was maybe 2-3 years after the 6th grade. Also, vector graphic games like Star Wars were a huge inspiration.

Most of the stuff I post is meant for inspiration. Sometimes I know it is too much detail oriented, especially the code. But if it inspires one person then that's a good thing.

The PVB currently has 2 16Kx11 blockRAMs which are meant for X and Y plot scratchpad information for the cpu which is a 65Org16.b. It's basically a 16-bit 6502 with some bells and whistles.

There is also a 10-bit hardware sine LUT present inside the FPGA. The cpu outputs a phase number from 0 to 1023 into that module, and awaiting on the cpu bus is the sinewave data.

The reason for 11-bits in the blockRAMs and 10-bit sine LUT, is so that one can add offsets to the sine LUT data and just plot the values from the scratchpad BRAMs within the 1920x1080 grid. I had wrestled with making the scratchpad BRAMs only 10-bits wide, but the software got messy trying to place waveforms with offsets.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 7:43 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
So first thing was to know exactly what the sinewave LUT was outputting. This LUT is a module created by the Xilinx Core Generator tool in ISE14.1, I chose the DDS compiler. It is very conservative as far as resources used.


Attachments:
File comment: set LUT for 1K width & depth
SIN LUT1.jpg
SIN LUT1.jpg [ 87.06 KiB | Viewed 2436 times ]
File comment: set for sine only, full amplitude
SIN LUT2.jpg
SIN LUT2.jpg [ 86.35 KiB | Viewed 2436 times ]
File comment: set for 1 cycle lookup
SIN LUT3.jpg
SIN LUT3.jpg [ 83.75 KiB | Viewed 2436 times ]
File comment: final settings confirmation
SIN LUT4.jpg
SIN LUT4.jpg [ 88.41 KiB | Viewed 2436 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 7:55 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
After some tweaks to the LUT interface, I was able to get good data. I had half sines in different portions of the screen before this code. Basically it adjusts the Y values for the 1080 vertical:
Code:
`timescale 1ns / 1ps
module sin_IF ( input clk,
               input [31:0] cpuAB,
               input [15:0] cpuDO,
               output reg [15:0] cpuDI,
               input cpuWE,
               input phaseEN,                           //phaseEn = 1 when 32'hB000_0000 - 32'hBFFF_FFFF is on cpu address bus
               output reg [SINaw-1:0] phase = 0,
               input [SINaw-1:0] sin_in
               );

parameter SINaw = 10;

always @(posedge clk) begin                              //write to phase register
   if (cpuWE && phaseEN && cpuAB [1:0] == 2'b00)
      phase <= cpuDO;
   
   if (!cpuWE && phaseEN && phase > 512)                  //read from sine LUT
      cpuDI <= sin_in - 512;
   if (!cpuWE && phaseEN && phase <= 512)
      cpuDI <= sin_in + 512;
   
      else if (!phaseEN)
         cpuDI <= 16'h0000;
end

endmodule

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 8:02 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Now I remembered from days past that to plot a circle in an X/Y system using sine/cosine values all one had to do is put sine values in the X and cosine values in the Y. Since cosine is sin shifted by 1/4 full cycle timewise, we don't really need cosine in this application. The X value is sine the Y value is sine+1/4=cosine(256/1024)
The code below illustrates this idea. In addition, it adds vertical and horizontal offsets through XORG and YORG for easy plotting. This is why I decided to keep the scratchpad BRAMs at 11-bits for 1920x1080 resolution. Also it divides the data from the LUT by 4 by performing 2x LSR. This code only takes data from the LUT, the cpu modifies it and then places it in BRAM:
Code:
;---------  Circle/Ellipse Generator from sine wave LUT
                  LDA #750
                  STA XORG
                  LDA #350
                  STA YORG
                 
                  LDWi $0000             
                  LDX #0
                  LDY #256
sinwave1          STX phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC XORG
                  STAaw scratchx1       
                  STY phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC YORG
                  STAaw scratchy1       
                  CPX #1023
                  BMI XNZ1
                  LDX #0
XNZ1              INX                   
                  CPY #1023
                  BMI YNZ1
                  LDY #0
YNZ1              INY
                  INW
                  CPWi $03FF             
                  BNE sinwave1


This simple code takes the data from the scratch BRAM and plots it. It's got to be simple, or I won't tolerate it.
ONE IMPORTANT NOTE:
When Y=0, a dot will be placed at 6o'clock.
When Y=256, a dot will be placed at 3o'clock.
When Y=512, a dot will be placed at 12o'clock.
When Y=768, a dot will be placed at 9o'clock.
Code:
                  LDX #1            ;white
                  LDA CLUT,X
                  STA color
                 
                  LDY #0
plot1             LDA scratchx1,Y
                  STA Xp
                  LDA scratchy1,Y
                  STA Yp
                  INY
                  CPY #1023
                  BMI plot1


Attachments:
circle from 1024-point LUT.JPG
circle from 1024-point LUT.JPG [ 47.72 KiB | Viewed 2435 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 8:52 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I'm going for a 3-D rotating cube with some special effects. :wink:

Software for first square face of cube inside the circle:
Code:
triplot           LDX #5            ;green
                  LDA CLUT,X
                  STA color
                 
                  BCF1C $FFFE              ;Branch if Control Flag 1 is Clear (0), CF1 is VSYNC input, so branch to itself and wait until vsync = 1, a non display period

                  LDY #128                 ;1st SQUARE OF CUBE
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #512+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #768+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1


Attachments:
1st face.JPG
1st face.JPG [ 43.36 KiB | Viewed 2436 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 9:00 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Now 2 scratchpads for 2 circles offset for a cube structure, I tried to come up with a quick calculation for the unit length. It didn't work at first so I placed a set value for UNITL:
Code:
;---------  Circle/Ellipse Generator from sine wave LUT
                  LDA #750
                  STA XORG
                  LDA #350
                  STA YORG
                 
                  LDWi $0000             
                  LDX #0
                  LDY #256
sinwave1          STX phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC XORG
                  STAaw scratchx1       
                  STY phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC YORG
                  STAaw scratchy1       
                  CPX #1023
                  BMI XNZ1
                  LDX #0
XNZ1              INX                   
                  CPY #1023
                  BMI YNZ1
                  LDY #0
YNZ1              INY
                  INW
                  CPWi $03FF             
                  BNE sinwave1
                 
                  ;LDY #128 + 768                   ;unit length calculation
                  ;LDA scratchy1,Y
                  ;LDY #128
                  ;SEC
                  ;SBC scratchy1,Y
                  ;LSR
                  LDA #85
                  STA UNITL                 
                 
                  LDWi $0000             
                  LDX #0
                  LDY #256
sinwave2          STX phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC XORG
                  ADC UNITL
                  STAaw scratchx2       
                  STY phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC YORG
                  ADC UNITL
                  STAaw scratchy2       
                  CPX #1023
                  BMI XNZ2
                  LDX #0
XNZ2              INX                   
                  CPY #1023
                  BMI YNZ2
                  LDY #0
YNZ2              INY
                  INW
                  CPWi $03FF             
                  BNE sinwave2

That was for the circles, which are virtex modifiers. Now 2 squares set inside 2 circles.
KEEP IN MIND EVERY TIME THE HARDWARE LINE GENERATOR SEES THE ADDRESS ly1, regardless of read or write, IT AUTO DRAWS from (lx0,ly0) to (lx1,ly1):
Code:
triplot           LDX #5            ;green
                  LDA CLUT,X
                  STA color
                 
                  BCF1C $FFFE              ;Branch if Control Flag 1 is Clear (0), CF1 is VSYNC input, so branch to itself and wait until vsync = 1, a non display period

                  LDY #128                 ;1st SQUARE OF CUBE
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #512+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #768+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1
                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1                 
                                            ;2nd SQUARE OF CUBE
                  LDY #128
                  LDA scratchx2,Y
                  STA lx0
                  LDA scratchy2,Y
                  STA ly0
                 
                  LDY #256+128
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDA scratchx2,Y
                  STA lx0
                  LDA scratchy2,Y
                  STA ly0
                 
                  LDY #512+128
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDA scratchx2,Y
                  STA lx0
                  LDA scratchy2,Y
                  STA ly0
                 
                  LDY #768+128
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDA scratchx2,Y
                  STA lx0
                  LDA scratchy2,Y
                  STA ly0
                 
                  LDY #128
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1


Attachments:
2nd face.JPG
2nd face.JPG [ 221.7 KiB | Viewed 2438 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 9:23 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Now to add the 4 diagonal interconnects:
Code:
                                          ;DIAGONAL INTERCONNECTS
                  LDY #128                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #512+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #768+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1


Attachments:
3D Cube.JPG
3D Cube.JPG [ 225.99 KiB | Viewed 2437 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 9:50 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Time for macros! :D They would dramatically shorten the source code and make it more clear, and still assemble the same result.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 9:53 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
So now, it would be neat to rotate one of the squares for an cool effect soon, but first...
I shift the Y index for the X sine on both of the LUTs represented as the circles currently, in order to make an ellipse. When X=0, Y=256 you get a circle. When X=812(arbitrary), Y=256 you get ellipse...
Code:
;---------  Circle/Ellipse Generator from sine wave LUT
                  LDA #750
                  STA XORG
                  LDA #350
                  STA YORG
                 
                  LDWi $0000             
                  LDX #812
                  LDY #256
sinwave1          STX phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC XORG
                  STAaw scratchx1       
                  STY phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC YORG
                  STAaw scratchy1       
                  CPX #1023
                  BMI XNZ1
                  LDX #0
XNZ1              INX                   
                  CPY #1023
                  BMI YNZ1
                  LDY #0
YNZ1              INY
                  INW
                  CPWi $03FF             
                  BNE sinwave1
                 
                  ;LDY #128 + 768                   ;unit length calculation
                  ;LDA scratchy1,Y
                  ;LDY #128
                  ;SEC
                  ;SBC scratchy1,Y
                  ;LSR
                  LDA #85
                  STA UNITL                 
                 
                  LDWi $0000             
                  LDX #812
                  LDY #256
sinwave2          STX phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC XORG
                  ADC UNITL
                  STAaw scratchx2       
                  STY phase
                  LDA sinout
                  LSR
                  LSR
                  CLC
                  ADC YORG
                  ADC UNITL
                  STAaw scratchy2       
                  CPX #1023
                  BMI XNZ2
                  LDX #0
XNZ2              INX                   
                  CPY #1023
                  BMI YNZ2
                  LDY #0
YNZ2              INY
                  INW
                  CPWi $03FF             
                  BNE sinwave2


Attachments:
3D cube mod.JPG
3D cube mod.JPG [ 203.26 KiB | Viewed 2429 times ]

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502
Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 10:24 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
GARTHWILSON wrote:
Time for macros! :D They would dramatically shorten the source code and make it more clear, and still assemble the same result.

Great, give us an example Garth!

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 11:13 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
ElEctric_EyE wrote:
GARTHWILSON wrote:
Time for macros! :D They would dramatically shorten the source code and make it more clear, and still assemble the same result.

Great, give us an example Garth!

Actually, in the portion
Code:
                  LDY #128                 
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #512+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1
                 
                  LDY #768+128
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1

there's more similarity that I saw at first glance, and the
Code:
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                  LDA scratchx2,Y
                  STA lx1
                  LDA scratchy2,Y
                  STA ly1

portion could even be a subroutine, unless you don't want the JSR/RTS overhead, in which case you could make it a macro and include the LDY# line, like
Code:
FOOBAR: MACRO  input        ; (Give it a descriptive name though.)
        LDY  #input
        LDA  scratchx1,Y
        STA  lx0
        LDA  scratchy1,Y
        STA  ly0
        LDA  scratchx2,Y
        STA  lx1
        LDA  scratchy2,Y
        STA  ly1
        ENDM
 ;------------------

and then replace the entire first section above with
Code:
        FOOBAR  128
        FOOBAR  256+128
        FOOBAR  512+128
        FOOBAR  768+128

taking it from 39 lines down to four.

In applications that have a lot of LDA#...STA_abs, I like to use a macro I call PUT, like this:
Code:
        PUT  750, IN, XORG
        PUT  350, IN, YORG

(Macros require commas separating the input parameters.) The "IN" is previously defined as 0 and is not actually used in the macro, being there only to make it more English-like.

When there are a lot of LDA_abs, STA_abs, I like to use a macro I call COPY, like this:
Code:
        COPY  FOOBAR, TO, XLERB

(Again, "TO" is only there to make it more English-like, and is not actually used by the macro.) You could go further and add another parameter telling how many address units to copy, so if you had a 32- or 64-bit quantity to copy, it would all get handled in one line.

You also have a lot of occurrences of LSR LSR (two lines), so it would be worth making those a macro and call it LSR2 for example, and then it only uses one line each time instead of two.

The macros for looping, conditional branching, etc, giving it all a more-visible structure are extra, and now I'm hooked on them and never want to go back.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 02, 2014 11:35 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
GARTHWILSON wrote:
Code:
FOOBAR: MACRO  input        ; (Give it a descriptive name though.)
        LDY  #input
        LDA  scratchx1,Y
        STA  lx0
        LDA  scratchy1,Y
        STA  ly0
        LDA  scratchx2,Y
        STA  lx1
        LDA  scratchy2,Y
        STA  ly1
        ENDM
 ;------------------

and then replace the entire first section above with
Code:
        FOOBAR  128
        FOOBAR  256+128
        FOOBAR  512+128
        FOOBAR  768+128

taking it from 39 lines down to four..

Sweet! I admit, this is nice from a programmer's POV.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 04, 2014 12:25 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I should mention, I use macros. Currently about 16,000 lines of them, but they are only to define some of the new 65Org16.b opcodes, not to crunch software.
Like above when I use the 'W' register:
Code:
STAaw scratchy1

the macro is:
Code:
STAaw             .MACRO param          ;STA $xxxxxxxx,w
                  .BYTE $009B
                  .WORD  param
                  .ENDM


My focus is more on making the machine work at this point, but what you have shown I like and I'll incorporate into future software posts.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 04, 2014 1:12 am 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
And what about when one needs to pass potentially 2 variables like in this situation:
Code:
                  LDY #128                 ;1st LINE of SQUARE OF CUBE
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1

It would be tolerable for X, Y, or W values to be used for the different Y values, but what is the syntax? Also, where are the syntax rules specifying these things I ask about?

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 04, 2014 1:54 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Code:
                  LDY #128                 ;1st LINE of SQUARE OF CUBE
                  LDA scratchx1,Y
                  STA lx0
                  LDA scratchy1,Y
                  STA ly0
                 
                  LDY #256+128
                  LDA scratchx1,Y
                  STA lx1
                  LDA scratchy1,Y
                  STA ly1

If the input parameters are for the first and seventh lines, you could do something like
Code:
FOOBAR:  MACRO first_param, second_param  ; (Name them something meaningful if you like.)
         LDY  #first_param                ; 1st LINE of SQUARE OF CUBE
         LDA  scratchx1,Y
         STA  lx0
         LDA  scratchy1,Y
         STA  ly0
                 
         LDY  #second_param
         LDA  scratchx1,Y
         STA  lx1
         LDA  scratchy1,Y
         STA  ly1

         ENDM
 ;------------------

then invoke it with, in the case you gave,
Code:
         FOOBAR  128, 256+128

The three major assemblers I've used, from different suppliers, all do macros more or less the same, with only minor variations. They of course allow conditional assembly, plus most, or all, of the things you can do in non-macro situations. They don't all do everything I would like, but I've still been able to do most of what I want to. The macro is kind of a program for the assembler to run in order to form the code that the conditions dictate, and a macro may generate differing amounts and types of code depending on input parameters and other assembler EQUates and variables; so macro usage can actually be quite flexible. Then of course the benefit is that once you work out the internal details, you don't have to keep looking at them every time you use them, so you can focus better attention on where you're going with the project rather than with the mundane stuff.

I've been following your video posts with interest. The reason I have not commented much is because I don't know enough about video or HDL to comment. :lol:

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: