|
Post by mikiex on May 11, 2014 10:25:37 GMT -5
This Thread will be used to ask questions / give feed back Vectrex Programming Tutorial 1: Tools and Tech: vectrexprogramming.blogspot.co.uk/I think its kind of a bit rushed, but it would be good to have feedback especially from anyone who is wanting to learn, I want to know if there is anything you don't understand, or would like more explaining.
|
|
|
Post by gliptitude on May 19, 2014 13:04:54 GMT -5
Hey, I'm just posting (prematurely) since no one else has yet. I HAVE read through your tutorial, so don't think it's just sitting out there. .. I have very limited internet access, (usually just on my iPad at work) and can't generally download things. But I have my laptop out today for downloading this, among other things. Not sure when I will get real time to attempt this first lesson, but I'm sure I will have questions at that time.
Thanks for doing this! .. I am especially glad you start out with the tools collected together so everyone can be on the exact same page. Also it looks like you have been more explicit than others in instructing the process for producing the .BIN file.
|
|
|
Post by mikiex on May 19, 2014 14:09:50 GMT -5
Thanks gliptitude, Well I know also xefned, is also following it an others might in the future. Its quite hard to think back once you have accumulated some knowledge about what things you stumbled on. The tutorials out there are all great, but I wanted to try and fill in a few gaps if I can. Any questions are welcome, I need to have a think about what I'm going to do in the next one
|
|
|
Post by xefned on May 21, 2014 14:50:23 GMT -5
Thank you for filling in the gaps! There are a lot of things that the guys on the FB Vectrex group just seem to *know* but don't seem to be documented anywhere. That was probably hard earned knowledge, so thanks for helping us along. I was planning to PM gliptitude to make him aware of this thread. Glad you found it! This will help enormously in getting one's first ROM compiled. I struggled for hours with this. (before this lesson was posted) It was hard work, but I just kept hammering at it over the course of 3 days before I succeeded. I was working with 2 asm files: Salomon's Hello World example which errored out at line 37. I finally figured out (guessed) that the assembler couldn't work with labels larger than 8 characters. "hello_world_string:" was too long. Shortening it to "hello_world" worked. And a simple "Draws a figure" Chris Tumber demo that choked on the instruction: include "VECTREX.I I finally figured out my version of the assembler 1.0.3 was too old to do includes. Eventually I found a copy of 1.11 and I was able to generate S-record files. But it was still another 2 days before I figured out that my hex2bin was an intel and not a motorola hex2bin. I also had a terrible combination of tools that only ran in DOS coupled with ones that required windows. Finally I had a full working DOS setup running in DOS box. That is all just to say: this will save people a lot of time to have links to tools that work together. </ramble> I've completed Tutorial 1! Thanks. What's next? Drawing and animating a triangle (ship?)
|
|
|
Post by xefned on May 21, 2014 15:38:53 GMT -5
Lesson recap checklist: ✓ Read (and comprehend, mostly) Tumber primer ✓ Read through Salomon primer with special attention to the bios disassembly ✓ Download the tools and code from lesson one ✓ Change the title text. Change the position and size of the title text. Recompile and run in emulator. Reading comprehension: Q:) What does the Reset0Ref subroutine do? A:) This routine zeros the integrators, and resets the pen back to the origin. It leaves the integrators in zero mode, so nothing can be drawn until a move is done, or $D00C is set to 0xCE to bring ZERO high. This routine must be called every so often, to prevent your vectors from getting out of whack. Q:) How many bytes of "safe RAM" are available to the coder? A:) 874 Q:) Do you understand how to skip a byte for two byte labels? A:) No? Me neither. But I get the concept. Extra credit:
Compile the Chris Tumber code: Draw_Line. Try changing the line coordinates.
|
|
|
Post by xefned on May 21, 2014 17:50:09 GMT -5
Should org 0be part of the "magic" init block?
Are there advantages to using the latest freeware assembler v1.42 for Vectrex coding? I wonder only because Ville Krumlinde, of Thrust, suggests sticking with an older version.
|
|
|
Post by christophertumber on May 21, 2014 20:55:28 GMT -5
The ORG statement is an assembler command ("pseudo instruction") that tells the assembler how to treat labels. It's used to tell the assembler how to "position" various blocks of code (segments) in memory.
ORG is often used in conjunction with "code", "data" and "bss" (other assemblers use "SEG") to tell the assembler whether that block should be part of the binary output or not (ie; when you assemble Vectrex source code you want the binary to be $0000-$7FFF and not to include $C880-$CBEA).
FWIW, I'm using v1.10 of Vorstenbosch's as09 and I probably always will. Compatibility problems from changing assemblers are a massive PITA.
BTW, I'm outputing straight to .bin and not using hex2bin. Command line is:
as09 -w200 -h0 -l -mcti -v specter.as9
|
|
|
Post by xefned on May 22, 2014 9:54:53 GMT -5
Thanks Chris!
Finding your assembly command a couple weeks ago is actually what made everything 'click.' You put that in the top of one of your source files. I tried it and discovered it spit out a .bin directly!
I'm using v1.11 for now. It was where the success began, so I stuck with it!
|
|
|
Post by xefned on May 23, 2014 16:31:32 GMT -5
Can anyone help shine a light on the available intensity levels for the vector beam?
The Salamon tutorial says: "There are two ways to control brightness. First the 'Intensity', which is a value from 0-$7f (if the 7th bit is set there is no intensity), 0 means black, $7f means full brightness."
But I can't find a 'chart' that lists the number of levels or values. I thought I would be clever and consult the VECTREX.I file assuming all values would be represented. Is this thinking correct? It lists shorthand for 1, 3, 5, 7, and a. Does this mean there are 5 levels of brightness, plus 0?
Intensity_1F equ $F29D ; Intensity_3F equ $F2A1 ; Intensity_5F equ $F2A5 ; Intensity_7F equ $F2A9 ; Intensity_a equ $F2AB ;
|
|
|
Post by christophertumber on May 25, 2014 10:32:56 GMT -5
#$7F is used most of the time for intensity because:
- Intensity is highly dependent on the individual machine's brightness knob. - Intensity is highly dependent on the individual machine's calibration. - Maximum brightness will take the longest for phosphors to fade, which is helpful if there would otherwise be any flicker. - Maximum brightness increases persistence of vision, which is helpful if there would otherwise be any flicker.
AFAIK, it's analog with valid values up to #$7F. However this is the kind of thing you could throw some code together quickly to test. When you're dealing with these kind of retro systems a lot of the time things are undocumented or poorly documented - There may have been manuals or books that have never made it to the Internet but often even back in the day information may not generally available depending on value (example: A number of Commodore 64 programming books included raster interrupts but usually only for split screens. If you wanted to do rasterbars you needed to figure it out for yourself, disassemble someone's demo or find someone to teach you). You really can't be afraid to experiment and invent.
Try this:
;*************************************************************************** ;Vectrex Analog Intensity Test ;Copyright 2014 Christopher L. Tumber ;For educational use only ;***************************************************************************
;*************************************************************************** ; DEFINE SECTION ;*************************************************************************** VIA_t1_cnt_lo EQU $d004 Vec_Misc_Count EQU $c823 clear_256_bytes EQU $f545 read_switches EQU $f1b4 read_joystick EQU $f1f8 display_string EQU $f495 print_at_d EQU $f37a waitrecal EQU $f192 move_pen7f_to_d EQU $f2fc intensity_to_A EQU $f2ab draw_to_d EQU $f3df move_pen_d EQU $f312 reset0ref EQU $f354 move_draw_VL4 EQU $f3b7 random EQU $f511 dot_here EQU $f2c5 set_dft_score EQU $f84f add_score_d EQU $f87c add_score_a EQU $f85e new_high_score EQU $f8d8 music EQU $FD0D Intensity_3F EQU $F2A1 Intensity_5F EQU $F2A5 Intensity_7F EQU $F2A9
Intensity1 EQU $C880 Intensity2 EQU $C881
Temporary_Variable EQU $C882 Temporary_String EQU $C883
; start of vectrex memory with cartridge name... ORG 0 ;*************************************************************************** ; HEADER SECTION ;*************************************************************************** FCB $67,$20 FCC "GCE " FCB $80 FDB music FDB $f070 FDB $30c0 FCC " " FCB $80,$0 ;*************************************************************************** ; CODE SECTION ;*************************************************************************** ; here the cartridge program starts off
setup: lda #$5F sta Intensity1 sta Intensity2
main: jsr waitrecal ; Vectrex BIOS recalibration
;This section draws the hexadecimal values of each intensity
;This is the first variable intensity lda #-63 ;Get Y position ldb #-127+50 ;Get X position jsr move_pen7f_to_d ;Move to there lda Intensity1 ;Get the intensity jsr draw_hex ;Draw hexadecimal value
;This is the second variable intensity lda #-63 ldb #-127+50+50+50 jsr move_pen7f_to_d lda Intensity2 jsr draw_hex
;This intensity is set to #$3F lda #-63 ldb #-127 jsr move_pen7f_to_d lda #$3F jsr draw_hex
;This intensity is set to #$5F lda #-63 ldb #-127+50+50 jsr move_pen7f_to_d lda #$5F jsr draw_hex
;This intensity is set to #$7F lda #-63 ldb #-127+50+50+50+50 jsr move_pen7f_to_d lda #$7F jsr draw_hex
;This section draws the rectangles used to compare intensity
;This is the first variable intensity lda Intensity1 jsr intensity_to_A lda #-63+20 ldb #-127+50 jsr draw_rectangle
;This is the second variable intensity lda Intensity2 jsr intensity_to_A lda #-63+20 ldb #-127+50+50+50 jsr draw_rectangle
;This intensity is set to #$3F lda #$3F jsr intensity_to_A lda #-63+20 ldb #-127 jsr draw_rectangle
;This intensity is set to #$5F lda #$5F jsr intensity_to_A lda #-63+20 ldb #-127+50+50 jsr draw_rectangle
;This intensity is set to #$7F lda #$7F jsr intensity_to_A lda #-63+20 ldb #-127+50+50+50+50 jsr draw_rectangle
;This section reads the buttons and adjusts the intensities
lda #$ff jsr read_switches lda $C812 ;Get 1 button beq no_int_change1 dec Intensity1 no_int_change1: lda $C813 ;Get 2 button beq no_int_change2 inc Intensity1 no_int_change2: lda $C814 ;Get 3 button beq no_int_change3 dec Intensity2 no_int_change3: lda $C815 ;Get 3 button beq no_int_change4 inc Intensity2 no_int_change4:
jmp main
draw_rectangle: jsr move_pen7f_to_d lda #63 ldb #0 jsr draw_to_d lda #0 ldb #25 jsr draw_to_d lda #-63 ldb #0 jsr draw_to_d lda #0 ldb #-25 jsr draw_to_d jsr reset0ref rts
draw_hex: sta Temporary_Variable ;Store the intensity variable so we can use it again ldx #Hex ;Point the X register at the start of the hexadecimal character table
lsra ;Move upper nybble (4 bits) to lower nybble (4 bits) lsra lsra lsra ldb a,x ;Get Hexadecimal character stb Temporary_String ;Store it as the first character in our string
lda Temporary_Variable ;Get intensity variable again anda #$0F ;Get lower nybble only ldb a,x ;Get Hexadecimal character stb Temporary_String+1 ;Store it as the second character in our string lda #$80 ;Set End of String sta Temporary_String+2
ldu #Temporary_String ;Point U register at start of string jsr display_string ;Print it jsr reset0ref rts
;*************************************************************************** ; DATA SECTION ;***************************************************************************
;Really lazy Hexadecimal conversion Hex: FCC "0" FCC "1" FCC "2" FCC "3" FCC "4" FCC "5" FCC "6" FCC "7" FCC "8" FCC "9" FCC "A" FCC "B" FCC "C" FCC "D" FCC "E" FCC "F"
|
|
|
Post by Malban on Jun 28, 2014 11:18:13 GMT -5
Just to say "Hi"!
Haven't done any Vectrex stuff in ages. I just discovered this board!
Saying "Hi" to everyone! :-)
Chris (Salomon)
|
|
|
Post by christophertumber on Jun 28, 2014 12:34:23 GMT -5
|
|
|
Post by vectrexrc on Jun 28, 2014 14:56:34 GMT -5
can someone explain the use of scale factors for drawing vector shapes? is using a small or large scale factor preferable? does it affect drawing performance?
|
|
|
Post by christophertumber on Jun 28, 2014 17:09:38 GMT -5
can someone explain the use of scale factors for drawing vector shapes? is using a small or large scale factor preferable? does it affect drawing performance? The scale is simply a timer. Literally. The scale value used gets put into VIA (Video Interface Adapter) at $D004 which is the low byte of timer 1. So if you draw vector (10,20) at a scale of 30, you are telling the hardware, "Draw in the direction (10,20) for 30 cycles". If you draw a vector (20,40) at a scale of 15, you are telling the hardware, "Draw in the direction (20,40) for 15 cycles". These will result in almost identical vectors (the hardware is analog so precision is an issue which tends to compound itself with continued drawing - vector drift and wobble. So you generally want to stick to a single scale for any specific object and to zero out the integrators regularly) however, the second version will take half as long. You generally want to draw at the smallest scale possible. I have an excel spreadsheet I used to optimize any set of vectors. Though again, the thing to remember is if you want your vectors to align properly, especially for large objects and doubly so for closed shapes, you may need to maintain a constant scale and reset0ref regularly. So absolute optimization is not always possible.
|
|
|
Post by vectrexrc on Jun 28, 2014 18:46:40 GMT -5
when drawing vectors you want to minimize the number of cycles - so why in your example would you ever choose to use the scale 30 instead of 15?
|
|