123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233 |
- **********************************
- **** DISPLAY_GRAPHIC_LIST *****
- **********************************
- display_graphic_buttons
- move.l #top_level_list,a0
- bsr remove_button_list
- move.l #graphic_page_buttons,a0 ;depress current page
- moveq #0,d0
- move.w current_page,d0
- asl.w #2,d0
- move.l (a0,d0.w),a0
- move.b #1,button_start(a0)
-
- move.w #2,edit_mode
- move.l #graphic_list,a0
- bsr display_button_list
- bsr clear_screen
- bsr reset_all_page_positions
- bsr display_graphic_page
- rts
- **********************************
- **** REMOVE_GRAPHIC_LIST *****
- **********************************
- remove_graphic_buttons
- move.l #graphic_list,a0
- bsr remove_button_list
- move.w #0,edit_mode
- move.w #0,sprite_to_attach
- tst generic_button_up
- beq.s button_not_up
- move.l #detect_generic_button,a0
- bsr remove_button
- button_not_up
- move.l #top_level_list,a0
- bsr display_button_list
- bsr clear_screen
- bsr reset_all_page_positions
- rts
- **********************************
- **** CANCEL BLOCK OPS *****
- **********************************
- cancel_block_ops
- move.l #detect_generic_button,a0
- bsr remove_button
- move.w #0,generic_button_up
- move.w #0,sprite_to_attach
- rts
- **********************************
- **** RESET ALL PAGE POSITIONS *****
- **********************************
- reset_all_page_positions
- move.l #picture_pages,a0
- move.w #5-1,d0
- reset_all
- move.l (a0),a1
-
- move.w #0,screen_y_pos(a1)
- addq.l #4,a0
- dbra d0,reset_all
-
-
- rts
- **********************************
- **** LOAD AN IMAGE FILE *****
- **********************************
- Load_an_Image_File
- move.l #Read_IFF_Image_File,File_Routine_Pointer
- bsr display_file_request
- rts
- **********************************
- **** READ IFF IMAGE FILE *****
- **********************************
- Read_IFF_Image_File
- movem.l a6,-(sp)
- move.l #Current_Filename,d1
- move.l #MODE_OLD,d2
- move.l dosbase,a6
- jsr Open(a6)
- movem.l (sp)+,a6
- tst.l d0
- beq.s couldnt_load_it
- movem.l d0,-(sp)
- bsr remove_file_request
- movem.l (sp)+,d0
- movem.l d0/a0,-(sp)
- move.w current_page,d0
- mulu #FILENAME_LENGTH,d0
- move.l #Current_Filename,a0
- jsr Set_Project_Information
- movem.l (sp)+,d0/a0
-
- bsr Load_Graphics
- cmp.l #-1,a1
- bne.s no_errors_here
- bsr error_routine
- rts
- couldnt_load_it
- bsr display_error
- rts
- no_errors_here
- bsr display_graphic_page
- rts
- ************************************
- **** DISPLAY GRAPHIC PAGE ****
- ************************************
- display_graphic_page
- move.l page_pointer,a0
- move.l screen_palette(a0),a1
- bsr setup_screen_colours
- move.l #main_screen_struct,a2
- move.w screen_y_pos(a0),d0
- move.w screen_x_size(a2),d1
- asr.w #3,d1
- mulu d0,d1
- move.w number_of_planes(a0),d7
-
- move.l screen_mem(a0),a0
- beq.s quit_display_page
- data_present
- add.l d1,a0
- move.l screen_mem(a2),a1
- move.w screen_x_size(a2),d0
- asr.w #3,d0
- mulu screen_y_size(a2),d0
- mulu d7,d0
- asr.l #2,d0
- subq.w #1,d0
- fill_loop
- move.l (a0)+,(a1)+
- dbra d0,fill_loop
- quit_display_page
- jsr Display_Overlays
- rts
-
- ********************************
- **** CHANGE PAGE *****
- ********************************
- change_page
- move.l clicked_button,a0
- moveq #0,d0
- move.b button_data(a0),d0
- subq.w #1,d0
- cmp.w current_page,d0
- bne.s not_clicked_on_same_butt
- move.b #DEPRESSED,button_start(a0)
- bra.s update_gr_button
- not_clicked_on_same_butt
- moveq #0,d1
- move.w current_page,d1
- move.w d0,current_page
-
- move.l #graphic_page_buttons,a0
- asl.w #2,d1
- move.l (a0,d1.w),a0
- move.b #NOT_DEPRESSED,button_start(a0)
- update_gr_button
- bsr remove_button
- bsr display_button
- move.l #picture_pages,a0
- moveq #0,d0
- move.w current_page,d0
- asl.w #2,d0
- move.l (a0,d0.w),page_pointer
- bsr display_graphic_page
- rts
-
- current_page
- dc.w 0
-
-
-
- ***************************************
- **** CHANGE GRAPHICS POSITION UP *****
- ***************************************
- change_graphics_position_up
- move.l #main_screen_struct,a0
- move.w screen_y_size(a0),d0
- sub.w #BUTTON_WINDOW_OFFSET,d0 ; gives part of screen hiding
- move.l page_pointer,a0
- tst.l screen_mem(a0)
- beq.s no_more_scroll
- cmp.w screen_y_pos(a0),d0
- beq.s no_more_scroll
- move.l current_map_ptr,a1
- move.w map_block_size(a1),d0
- add.w d0,screen_y_pos(a0)
- bsr display_graphic_page
- no_more_scroll
- rts
-
-
- ******************************************
- **** CHANGE GRAPHICS POSITION DOWN *****
- ******************************************
- change_graphics_position_down
- move.l page_pointer,a0
- tst.l screen_mem(a0)
- beq.s no_more_scroll
- cmp.w #0,screen_y_pos(a0)
- ble.s no_more_scrolld
- move.l current_map_ptr,a1
- move.w map_block_size(a1),d0
- sub.w d0,screen_y_pos(a0)
- bsr display_graphic_page
- no_more_scrolld
- rts
-
-
- store_x dc.w 0
- store_y dc.w 0
- store_off_y dc.w 0
- store_page dc.l 0
-
- ******************************************
- **** CONVERT MOUSE AND STORE *****
- ******************************************
- convert_mouse_and_store
- move.l a0,-(sp)
- moveq #0,d0
- moveq #0,d1
- moveq #0,d2
- moveq #0,d3
- move.w mouse_x,d0
- move.w mouse_y,d1
-
- move.w store_x,d2
- move.w store_y,d3
-
- move.l current_map_ptr,a0
-
- cmp.w #8,map_block_size(a0)
- bne.s check_if_16
- andi.w #$fff8,d0
- andi.w #$fff8,d1
- andi.w #$fff8,d2
- andi.w #$fff8,d3
- bra.s done_blocks
- check_if_16
- cmp.w #16,map_block_size(a0)
- bne.s check_if_32
- andi.w #$fff0,d0
- andi.w #$fff0,d1
- andi.w #$fff0,d2
- andi.w #$fff0,d3
- bra.s done_blocks
- check_if_32
- andi.w #$ffe0,d0
- andi.w #$ffe0,d1
- andi.w #$ffe0,d2
- andi.w #$ffe0,d3
- done_blocks
- move.l (sp)+,a0
- rts
-
- ******************************************
- **** COPY BLOCK TO BLOCK *****
- ******************************************
- copy_block_to_block
- *send a0 and a1 as start and dest
- *send number of planes in d7
- movem.l a0-a5/d0-d3/d7,-(sp)
-
- move.l current_map_ptr,a2
- move.l #main_screen_struct,a3
- subq.w #1,d7
- move.w map_block_size(a2),d0
- copy_planes
- move.l a0,a4
- move.l a1,a5
- move.w d0,d1
- move.w d0,d3
- subq.w #1,d3
- copy_to_new_position
- cmp.w #8,d1
- bne.s copy16
- move.b (a4),(a5)
- bra.s update_line
- copy16
- cmp.w #16,d1
- bne.s must_be_32
- move.w (a4),(a5)
- bra.s update_line
- must_be_32
- move.l (a4),(a5)
- update_line
- moveq #0,d2
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- add.l d2,a4
- add.l d2,a5
- dbra d3,copy_to_new_position
-
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- mulu screen_y_size(a3),d2
- add.l d2,a1
- add.l d2,a0
- dbra d7,copy_planes
- movem.l (sp)+,a0-a5/d0-d3/d7
- rts
-
- ******************************************
- **** COPY BLOCK TO BUFFER *****
- ******************************************
- copy_block_to_buffer
- *send a0 and a1 as start and dest
- *send number of planes in d7
- *a1 contains buffer addr
- movem.l a0-a5/d0-d3/d7,-(sp)
-
- move.l current_map_ptr,a2
- move.l #main_screen_struct,a3
- subq.w #1,d7
- move.w map_block_size(a2),d0
- buffcopy_planes
- move.l a0,a4
- move.w d0,d1
- move.w d0,d3
- subq.w #1,d3
- buffcopy_to_new_position
- cmp.w #8,d1
- bne.s buffcopy16
- move.b (a4),(a1)+
- bra.s buffupdate_line
- buffcopy16
- cmp.w #16,d1
- bne.s buffmust_be_32
- move.w (a4),(a1)+
- bra.s buffupdate_line
- buffmust_be_32
- move.l (a4),(a1)+
- buffupdate_line
- moveq #0,d2
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- add.l d2,a4
- dbra d3,buffcopy_to_new_position
-
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- mulu screen_y_size(a3),d2
- add.l d2,a0
- dbra d7,buffcopy_planes
- movem.l (sp)+,a0-a5/d0-d3/d7
- rts
- ******************************************
- **** COPY BUFFER TO BLOCK *****
- ******************************************
- copy_buffer_to_block
- *send a0 and a1 as start and dest
- *send number of planes in d7
- *a0 contains buffer addr
- movem.l a0-a5/d0-d3/d7,-(sp)
-
- move.l current_map_ptr,a2
- move.l #main_screen_struct,a3
- subq.w #1,d7
- move.w map_block_size(a2),d0
- bloccopy_planes
- move.l a1,a4
- move.w d0,d1
- move.w d0,d3
- subq.w #1,d3
- bloccopy_to_new_position
- cmp.w #8,d1
- bne.s bloccopy16
- move.b (a0)+,(a4)
- bra.s blocupdate_line
- bloccopy16
- cmp.w #16,d1
- bne.s blocmust_be_32
- move.w (a0)+,(a4)
- bra.s blocupdate_line
- blocmust_be_32
- move.l (a0)+,(a4)
- blocupdate_line
- moveq #0,d2
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- add.l d2,a4
- dbra d3,bloccopy_to_new_position
-
- move.w screen_x_size(a3),d2
- asr.w #3,d2
- mulu screen_y_size(a3),d2
- add.l d2,a1
- dbra d7,bloccopy_planes
- movem.l (sp)+,a0-a5/d0-d3/d7
- rts
- *****CODE TO MOVE A BLOCK
-
- ******************************************
- **** GET BLOCK POSITION *****
- ******************************************
- get_block_position
- move.w mouse_x,store_x
- move.w mouse_y,store_y
- move.l page_pointer,a0
- move.w screen_y_pos(a0),store_off_y
- move.l page_pointer,store_page
- move.w #TO,sprite_to_attach
- move.w #MODE_TO_MOVE_BLOCK,block_mode
- rts
- *******************PLEASE NOTE
- *when a picture is loaded it is always loaded into five planes
- *of memory this way when copying blocks around there is no
- *problem if a block is copied from a five plane picture
- *to a one plane picture
- *it is up to the user
-
- ******************************************
- **** FIND MOVE TO POSITION *****
- ******************************************
- find_move_to_position
- bsr convert_mouse_and_store
-
- move.l page_pointer,a0
- move.w d1,d6 ; store for later use
- add.w screen_y_pos(a0),d1
- move.l screen_mem(a0),a1
- asr.w #3,d0
- move.l #main_screen_struct,a2
- move.w screen_x_size(a2),d4
- asr.w #3,d4
- mulu d4,d1 ;get position down screen
- add.l d1,a1
- add.l d0,a1 ; a1 contains dest address
- move.l a1,a5
-
- move.l store_page,a3
- move.w number_of_planes(a2),d7
- move.w d3,d5
- add.w store_off_y,d3
- move.l screen_mem(a3),a0
- asr.w #3,d2
- mulu d4,d3
- add.l d3,a0
- add.l d2,a0 ;a0 contains start address
- move.l #block_buffer,a1
- bsr copy_block_to_buffer ;in buffer
-
- move.l a0,a1
- move.l #blank_buffer,a0
- bsr copy_buffer_to_block ; clear out source
-
- move.l #block_buffer,a0
- move.l a5,a1
- bsr copy_buffer_to_block ; copy to dest
- ***blank out position on screen
- move.l screen_mem(a2),a1
- mulu d4,d5
- add.l d5,a1
- add.l d2,a1
-
- move.l #blank_buffer,a0
- bsr copy_buffer_to_block
-
-
- move.l #block_buffer,a0
- move.l screen_mem(a2),a1
- add.l d0,a1
- mulu d4,d6
- add.l d6,a1
-
- bsr copy_buffer_to_block; copy to screen
-
-
- *now put back to pick stage
- quit_move_block
- move.w #PICK,sprite_to_attach
- move.w #MODE_MOVE_BLOCK,block_mode
-
- rts
-
- ******************************************
- **** GET COPY BLOCK POSITION *****
- ******************************************
- get_copy_block_position
- move.w mouse_x,store_x
- move.w mouse_y,store_y
- move.l page_pointer,a0
- move.w screen_y_pos(a0),store_off_y
- move.l page_pointer,store_page
- move.w #TO,sprite_to_attach
- move.w #MODE_TO_COPY_BLOCK,block_mode
- rts
-
- ******************************************
- **** FIND COPY TO POSITION *****
- ******************************************
- find_copy_to_position
- bsr convert_mouse_and_store
-
- move.l page_pointer,a0
- move.w d1,d6 ; store for later use
- add.w screen_y_pos(a0),d1
- move.l screen_mem(a0),a1
- asr.w #3,d0
- move.l #main_screen_struct,a2
- move.w screen_x_size(a2),d4
- asr.w #3,d4
- mulu d4,d1 ;get position down screen
- add.l d1,a1
- add.l d0,a1 ; a1 contains dest address
-
- move.l store_page,a3
- move.w number_of_planes(a2),d7
- add.w store_off_y,d3 ;add on old offset
- move.l screen_mem(a3),a0
- asr.w #3,d2
- mulu d4,d3
- add.l d3,a0
- add.l d2,a0 ;a0 contains start address
- bsr copy_block_to_block ; copy into page
-
- move.l screen_mem(a2),a1
- add.l d0,a1
- mulu d4,d6
- add.l d6,a1
-
- bsr copy_block_to_block; copy to screen
-
- *now put back to pick stage
- quit_copy_block
- move.w #PICK,sprite_to_attach
- move.w #MODE_COPY_BLOCK,block_mode
- rts
-
- *****CODE TO EXCHANGE A BLOCK
- ******************************************
- **** GET EXCHANGE BLOCK POSITION *****
- ******************************************
- get_exchange_block_position
- move.w mouse_x,store_x
- move.w mouse_y,store_y
- move.l page_pointer,a0
- move.w screen_y_pos(a0),store_off_y
- move.l page_pointer,store_page
- move.w #TO,sprite_to_attach
- move.w #MODE_TO_EXCHANGE_BLOCK,block_mode
- rts
-
- ******************************************
- **** FIND EXCHANGE TO POSITION *****
- ******************************************
- find_exchange_to_position
- bsr convert_mouse_and_store
-
- move.l page_pointer,a0
- move.w d1,d6 ; store for later use
- add.w screen_y_pos(a0),d1
- move.l screen_mem(a0),a1
- asr.w #3,d0
- move.l #main_screen_struct,a2
- move.w number_of_planes(a2),d7
- move.w screen_x_size(a2),d4
- asr.w #3,d4
- mulu d4,d1 ;get position down screen
- add.l d1,a1
- add.l d0,a1 ; a1 contains dest address
-
- move.l a1,a0
- move.l #block_buffer,a1
- bsr copy_block_to_buffer
- move.l a0,a4 ;store dest address
-
- move.l store_page,a3
- move.w d3,d5
- add.w store_off_y,d3 ;add on old offset
- move.l screen_mem(a3),a0
- asr.w #3,d2
- mulu d4,d3
- add.l d3,a0
- add.l d2,a0 ;a0 contains start address
- move.l #block_buffer2,a1
- bsr copy_block_to_buffer
-
- move.l a4,a1 ;dest address
- move.l a0,a4 ;store start address
- move.l #block_buffer2,a0
- bsr copy_buffer_to_block
-
- move.l a4,a1
- move.l #block_buffer,a0
- bsr copy_buffer_to_block
-
- move.l #block_buffer2,a0
- move.l screen_mem(a2),a1
- add.l d0,a1
- mulu d4,d6
- add.l d6,a1
- bsr copy_buffer_to_block ; copy to screen position 1
-
- move.l screen_mem(a2),a1
- add.l d2,a1
- mulu d4,d5
- add.l d5,a1
- move.l #block_buffer,a0
- bsr copy_buffer_to_block ; copy to screen position 2
-
- *now put back to pick stage
- move.w #PICK,sprite_to_attach
- move.w #MODE_EXCHANGE_BLOCK,block_mode
- rts
-
- **** xflip,yflip and rotate funcs
- ******************************************
- **** GET BLOCK OPS POSITION *****
- ******************************************
- get_block_ops_position
- move.l #block_op_routines,a0
- moveq #0,d0
- move.w current_block_op,d0
- add.l d0,a0
- move.l (a0),a0
- jsr (a0)
- rts
- ******************************************
- **** XFLIP THE BLOCK *****
- ******************************************
- xflip_the_block
- bsr convert_mouse_and_store
- move.l page_pointer,a0
- move.l #main_screen_struct,a1
- move.w screen_x_size(a1),d2
- asr.w #3,d2
- move.w d2,d3
- move.w d0,-(sp)
- move.w d1,-(sp)
- add.w screen_y_pos(a0),d1 ; add on offset
- move.l screen_mem(a0),a0
- asr.w #3,d0
- add.l d0,a0
- move.w d3,d5 ;for later
- mulu screen_y_size(a1),d3 ;for later
- move.w number_of_planes(a1),d0
- mulu d1,d2 ; y offset on page
- add.l d2,a0 ; block position
- move.l a0,a4 ; store
-
- move.l #block_buffer,a1 ; dest
- move.l current_map_ptr,a2
- move.w map_block_size(a2),d2
- subq.w #1,d0 ; number of planes
- xflip_planes_loop
- move.w d2,d6 ; map block size
- subq.w #1,d6
- move.l a0,a2
- block_lines_loop
- cmp.w #8,d2
- bne.s not_8x8
- bsr xflip_8x8
- bra.s update_xflip_planes
- not_8x8
- cmp.w #16,d2
- bne.s not_16x16
- bsr xflip_16x16
- bra.s update_xflip_planes
- not_16x16
- bsr xflip_32x32
- update_xflip_planes
-
- add.l d5,a2 ;move down one page line
- dbra d6,block_lines_loop
- add.l d3,a0 ;plane size
-
- dbra d0,xflip_planes_loop
-
-
- move.l a4,a1
- move.l #block_buffer,a0
- move.l #main_screen_struct,a2
- move.w number_of_planes(a2),d7
- bsr copy_buffer_to_block
-
- move.l #main_screen_struct,a1
- move.l screen_mem(a1),a1
- move.w (sp)+,d0
- mulu d5,d0
- add.l d0,a1
- moveq #0,d0
- move.w (sp)+,d0
- asr.w #3,d0
- add.l d0,a1
- bsr copy_buffer_to_block
-
- rts
-
- xflip_8x8
- movem.l a2-a3/d0,-(sp)
- moveq #7,d7
- move.b (a2),d4
- xflip_8x8_loop
- ror.b d4
- roxl.b d0
- dbra d7,xflip_8x8_loop
- move.b d0,(a1)+
- movem.l (sp)+,a2-a3/d0
- rts
-
- xflip_16x16
- movem.l a2-a3/d0,-(sp)
- moveq #15,d7
- move.w (a2),d4
- xflip_16x16_loop
- roxr.w d4
- roxl.w d0
- dbra d7,xflip_16x16_loop
- move.w d0,(a1)+
- movem.l (sp)+,a2-a3/d0
- rts
-
- xflip_32x32
- movem.l a2-a3/d0,-(sp)
- moveq #31,d7
- move.l (a2),d4
- xflip_32x32_loop
- roxr.l d4
- roxl.l d0
- dbra d7,xflip_32x32_loop
- move.l d0,(a1)+
- movem.l (sp)+,a2-a3/d0
- rts
-
-
- ******************************************
- **** YFLIP THE BLOCK *****
- ******************************************
- yflip_the_block
- bsr convert_mouse_and_store
- move.l page_pointer,a0
- move.w screen_y_pos(a0),d2
- move.l screen_mem(a0),a0
- asr.w #3,d0
- add.l d0,a0
- move.l #main_screen_struct,a1
- move.w screen_x_size(a1),d3
- asr.w #3,d3
- move.w d1,d4
- add.w d2,d4
- mulu d3,d4
- add.l d4,a0 ;source
- move.l a0,a4 ;store
-
- move.l current_map_ptr,a2
- move.w map_block_size(a2),d4
- move.w number_of_planes(a1),d5
- subq.w #1,d5
- yflip_planes
- move.l a0,a5
- move.w d4,d7
- subq.w #1,d7
- mulu d3,d7 ;end of block
- add.l d7,a5 ; end of block
-
- move.w d4,d7
- asr.w d7
- subq.w #1,d7
- move.l a0,a3
- yflip_lines
- cmp.w #8,d4
- bne.s yflip_16
- move.b (a3),d6
- move.b (a5),(a3)
- move.b d6,(a5)
- bra.s update_block_line
- yflip_16
- cmp.w #32,d4
- beq.s yflip_32
- move.w (a3),d6
- move.w (a5),(a3)
- move.w d6,(a5)
- bra.s update_block_line
- yflip_32
- move.l (a3),d6
- move.l (a5),(a3)
- move.l d6,(a5)
- update_block_line
- add.l d3,a3
- sub.l d3,a5
- dbra d7,yflip_lines
-
- move.w d3,d7
- mulu screen_y_size(a1),d7
- add.l d7,a0
- dbra d5,yflip_planes
-
- move.w number_of_planes(a1),d7
- move.l screen_mem(a1),a1
- mulu d3,d1
- add.l d1,a1
- add.l d0,a1
- move.l a4,a0
- bsr copy_block_to_block
-
- rts
- ******************************************
- **** ROTATE THE BLOCK *****
- ******************************************
- rotate_the_block
-
- bsr convert_mouse_and_store
- move.l page_pointer,a0
- move.w screen_y_pos(a0),d2
- move.l screen_mem(a0),a0
- asr.w #3,d0
- add.l d0,a0
- move.l #main_screen_struct,a1
- moveq #0,d3
- move.w screen_x_size(a1),d3
- asr.w #3,d3
- move.w d1,d4
- move.w d1,-(sp)
- add.w d2,d4
- mulu d3,d4
- add.l d4,a0 ;source
- move.l a0,a5 ;store
-
- move.l current_map_ptr,a2
- move.w map_block_size(a2),d4
- move.w number_of_planes(a1),d5
- subq.w #1,d5
- move.l #block_buffer,a4 ;dest
-
- rotate_planes_loop
- move.w d4,d2
- subq.w #1,d2
- move.l a0,a2
- rotate_lines_loop
- move.l a4,a3
- move.w d4,d7
- subq.w #1,d7
- rotate_bits_loop
-
- cmp.w #8,d4
- bne.s check_rot16
- move.b (a2),d6
- roxl.b d6
- move.b d6,(a2)
- move.b (a3),d6
- roxr.b d6
- move.b d6,(a3)+
- bra.s update_rot_line
- check_rot16
- cmp.w #16,d4
- bne.s rotate_32
- move.w (a2),d6
- roxl.w d6
- move.w d6,(a2)
- move.w (a3),d6
- roxr.w d6
- move.w d6,(a3)+
- bra.s update_rot_line
- rotate_32
- move.l (a2),d6
- roxl.l d6
- move.l d6,(a2)
- move.l (a3),d6
- roxr.l d6
- move.l d6,(a3)+
- update_rot_line
- dbra d7,rotate_bits_loop
-
- add.l d3,a2 ; next line of block
-
- dbra d2,rotate_lines_loop
-
- move.w d3,d7
- mulu screen_y_size(a1),d7
- add.l d7,a0
-
- move.w d4,d7
- asr.w #3,d7
- mulu d4,d7
- add.l d7,a4
-
- dbra d5,rotate_planes_loop
-
- move.w number_of_planes(a1),d7
- move.l #block_buffer,a0
- move.l a5,a1
- bsr copy_buffer_to_block
- move.l #main_screen_struct,a1
- move.l screen_mem(a1),a1
- move.w (sp)+,d4
- mulu d3,d4
- add.l d4,a1
- add.l d0,a1
- bsr copy_buffer_to_block
- rts
-
-
- *****CODE TO COMBINE A BLOCK
-
-
- ******************************************
- **** GET COMBINE BLOCK POSITION *****
- ******************************************
- get_combine_block_position
- move.w mouse_x,store_x
- move.w mouse_y,store_y
- move.l page_pointer,a0
- move.w screen_y_pos(a0),store_off_y
- move.l page_pointer,store_page
- move.w #WITH,sprite_to_attach
- move.w #MODE_TO_COMBINE_BLOCK,block_mode
- rts
-
- ******************************************
- **** FIND COMBINE WITH POSITION *****
- ******************************************
- find_combine_with_position
- bsr convert_mouse_and_store
-
- move.l a6,-(sp)
- moveq #0,d4
- move.l page_pointer,a0
- move.w d1,-(sp) ; store for later use
- add.w screen_y_pos(a0),d1
- move.l screen_mem(a0),a1
- asr.w #3,d0
- move.l d0,-(sp)
- move.l #main_screen_struct,a2
- move.w number_of_planes(a2),d7
- move.w screen_x_size(a2),d4
- asr.w #3,d4
- mulu d4,d1 ;get position down screen
- add.l d1,a1
- add.l d0,a1 ; a1 contains dest address
- move.l store_page,a3
- move.w d3,d5
- add.w store_off_y,d3 ;add on old offset
- move.l screen_mem(a3),a0
- asr.w #3,d2
- mulu d4,d3
- add.l d3,a0
- add.l d2,a0 ;a0 contains start address
- move.w #31,d3
- move.l #block_buffer,a6
- clear_mask_out
- clr.l (a6)+
- dbra d3,clear_mask_out
-
-
- move.l current_map_ptr,a4
- move.w map_block_size(a4),d2
-
- move.l a0,a6
- move.w number_of_planes(a2),d6
- subq.w #1,d6
- make_mask_planes
- move.l #block_buffer,a3
- move.l a6,a4
- move.w d2,d3
- subq.w #1,d3
- make_mask
- cmp.w #8,d2
- bne.s try16gfd
- move.b (a3),d5
- or.b (a4),d5
- move.b d5,(a3)+
- bra.s fuck_this
- try16gfd
- cmp.w #16,d2
- bne.s try32fdfds
- move.w (a3),d5
- or.w (a4),d5
- move.w d5,(a3)+
- bra.s fuck_this
- try32fdfds
- move.l (a3),d5
- or.l (a4),d5
- move.l d5,(a3)+
- fuck_this
- add.l d4,a4 ;next line
- dbra d3,make_mask
- move.l d4,d5
- mulu screen_y_size(a2),d5
- add.l d5,a6
- dbra d6,make_mask_planes
- **********finish
- move.l a1,a5
- move.l current_map_ptr,a4
- move.w map_block_size(a4),d2
- subq.w #1,d7
- combine_planes_loop
- move.l a0,a3
- move.l a1,a4
- move.l #block_buffer,a6
- move.w d2,d3
- subq.w #1,d3
- combine_planes_lines_loop
- ****add so block buffer in referenced for block mask
- cmp.w #8,d2
- bne.s combine_16
- move.b (a4),d6
- move.b (a6)+,d5
- not.b d5
- and.b d5,d6
- or.b (a3),d6
- move.b d6,(a4)
- bra.s update_combine_line
- combine_16
- cmp.w #16,d2
- bne.s combine_32
- move.w (a4),d6
- move.w (a6)+,d5
- not.w d5
- and.w d5,d6
- or.w (a3),d6
- move.w d6,(a4)
- bra.s update_combine_line
- combine_32
- move.l (a4),d6
- move.l (a6)+,d5
- not.l d5
- and.l d5,d6
- or.l (a3),d6
- move.l d6,(a4)
- update_combine_line
- add.l d4,a4
- add.l d4,a3
- dbra d3,combine_planes_lines_loop
-
- move.l d4,d5
- mulu screen_y_size(a2),d5
- add.l d5,a0
- add.l d5,a1
- dbra d7,combine_planes_loop
- move.l screen_mem(a2),a1
- move.w number_of_planes(a2),d7
- move.l (sp)+,d2
- add.l d2,a1
- move.w (sp)+,d2
- mulu d4,d2
- add.l d2,a1
- move.l a5,a0
- bsr copy_block_to_block ; copy to screen position 2
- move.l (sp)+,A6
- *now put back to pick stage
- *user must click exit to get out
- move.w #PICK,sprite_to_attach
- move.w #MODE_COMBINE_BLOCK,block_mode
- rts
-
- current_block_op
- dc.w 0
-
- block_op_routines
- dc.l xflip_the_block
- dc.l yflip_the_block
- dc.l rotate_the_block
- dc.l enter_block_into_group
- dc.l edit_single_block
- XFLIP EQU 0
- YFLIP EQU 1
- ROTATE EQU 2
-
-
- PICK EQU 1
- WITH EQU 2
- TO EQU 3
-
- sprite_to_attach
- dc.w 0
-
- block_buffer
- ds.w 32*5*2
-
- block_buffer2
- ds.w 32*5*2
-
- blank_buffer
- ds.w 32*5*2
-
-
-
- ***************************************
- ***** SELECT BLOCK MODE ****
- ***************************************
- select_block_mode
- move.l #detect_generic_button,a0
- bsr display_button
- move.l clicked_button,a0
- moveq #0,d0
- move.b button_data(a0),d0
- move.w d0,block_mode
- sub.w #MODE_XFLIP_BLOCK,d0
- move.w d0,current_block_op
- move.w #PICK,sprite_to_attach
- move.w #1,generic_button_up
- rts
- generic_button_up
- dc.w 0
-
- ***************************************
- ***** SELECT RELAVANT MODE ****
- ***************************************
- select_relavant_mode
- move.l #block_mode_table,a0
- moveq #0,d0
- move.w block_mode,d0
- move.l (a0,d0),a0
- jsr (a0) ;call function
- rts
-
- block_mode
- dc.w 0
-
-
- MODE_COPY_BLOCK EQU 0
- MODE_EXCHANGE_BLOCK EQU 4
- MODE_MOVE_BLOCK EQU 8
- MODE_COMBINE_BLOCK EQU 12
- MODE_TO_COPY_BLOCK EQU 16
- MODE_TO_EXCHANGE_BLOCK EQU 20
- MODE_TO_MOVE_BLOCK EQU 24
- MODE_TO_COMBINE_BLOCK EQU 28
- MODE_XFLIP_BLOCK EQU 32
- MODE_YFLIP_BLOCK EQU 36
- MODE_ROTATE_BLOCK EQU 40
- MODE_EDIT_BLOCK EQU 44
- MODE_EDIT_SINGLE_BLOCK EQU 48
- block_mode_table
- dc.l get_copy_block_position
- dc.l get_exchange_block_position
- dc.l get_block_position
- dc.l get_combine_block_position
-
- dc.l find_copy_to_position
- dc.l find_exchange_to_position
- dc.l find_move_to_position
- dc.l find_combine_with_position
-
- dc.l get_block_ops_position
- dc.l get_block_ops_position
- dc.l get_block_ops_position
- dc.l get_block_ops_position
- dc.l get_block_ops_position
|