RAM_StarTable: EQU $FF1000

stars:

    hex 00000eee0aaa0ccc08aa0a880666088804440666046408880aee0ece086608660866
    even


BMPVBLANK2:
    lea (RAM_Bitmap), a4
    move.w #128*64/4-1, d6

@Fubar:
    move.l #0, (a4)+
    dbf d6, @fubar
    rte


Starfield:

; Starfield management system


; 3584 / 4;;;;

ClearMemStar:

    singledmacram stars, 0, 32, Vdpcontrol
   jsr   Bitmap_InitVDP
   jsr   Bitmap_InitScrollMap
   jsr   Bitmap_InitInts
   disableints
;   move.w #$8174, (VDPCONTROL)
 ;  move.l #BMPVBLANK2, (RAM_VINTLOC+2)
   enableints


    lea (RAM_StarTable), a0
    moveq #0, d1
    move.w #(256/4)-1, d0
    lea (StarList), a1
@ClearLooperator:
    rept 8
        move.l (a1)+, (a0)+
    endr
    dbf d0, @ClearLooperator
;    jmp *
@Process:
    move.w #(5-1), d6

    lea (RAM_StarTable), a0
    lea (RAM_Bitmap), a1
    lea (DivTable), a2
@ProcessLoop:

; Limit is 64 BY 32 PIKSEL UNITS.
    ; Fetch XYZ Coordinates, divide X and Y by Z, and write to the btiedtojstgsmndpo
    moveq #0, d0
    moveq #0, d1
    moveq #0, d2
    moveq #0, d3
    move.b (a0), d0
    move.b 1(a0), d1
    move.b 2(a0), d2
    move.b 4(a0), d3
    move.b 5(a0), d4
    move.b 6(a0), d5
    add.b d0, d3
    add.b d1, d4
    add.b d2, d5

;    and.b #15, d5 
;  move.b d3, (a0)
 ; move.b d4, 1(a0)
  ;  move.b d5, 2(a0)
    
    addq #1, d2
    lsl.w #8, d2
    lsl.w #2, d2
    move.w d2, d3
    lsl.w #2, d0
    lsl.w #2, d1
    add.w d0, d2
    add.w d1, d3

    move.w (a2, d2.w), d0
    move.w (a2, d3.w), d1

    add.w #128, d0
    add.w #128, d1

    and.w #255, d0
    and.w #255, d1

    lsr.w #1, d0
    lsr.w #1, d1
    lsl.w #7, d1
    add.w d0, d1
    move.b $3(a0), (a1, d1.w)

    

    lea 8(a0), a0

	dbf		d6, @ProcessLoop

@Loop:

;   Do Drawing and Calculations here !

   DrawBitmap 64        ; THat's how easy it is :D!

   bra @Process


	jmp *

StarList:
    incbin ./bitmap/starfield.bin
    even