Procházet zdrojové kódy

add item image preview to giveitem, fixes #92

SBird1337 před 6 roky
rodič
revize
c35ebd627c
Signed by: SBird1337 <philipp@karathan.at> GPG Key ID: C9A4764515931448

+ 0
- 90
.clang-format Zobrazit soubor

@@ -1,90 +0,0 @@
1
----
2
-Language:        Cpp
3
-# BasedOnStyle:  LLVM
4
-AccessModifierOffset: -2
5
-AlignAfterOpenBracket: Align
6
-AlignConsecutiveAssignments: false
7
-AlignConsecutiveDeclarations: false
8
-AlignEscapedNewlinesLeft: false
9
-AlignOperands:   true
10
-AlignTrailingComments: true
11
-AllowAllParametersOfDeclarationOnNextLine: true
12
-AllowShortBlocksOnASingleLine: false
13
-AllowShortCaseLabelsOnASingleLine: false
14
-AllowShortFunctionsOnASingleLine: All
15
-AllowShortIfStatementsOnASingleLine: false
16
-AllowShortLoopsOnASingleLine: false
17
-AlwaysBreakAfterDefinitionReturnType: None
18
-AlwaysBreakAfterReturnType: None
19
-AlwaysBreakBeforeMultilineStrings: false
20
-AlwaysBreakTemplateDeclarations: false
21
-BinPackArguments: true
22
-BinPackParameters: true
23
-BraceWrapping:   
24
-  AfterClass:      false
25
-  AfterControlStatement: false
26
-  AfterEnum:       false
27
-  AfterFunction:   false
28
-  AfterNamespace:  false
29
-  AfterObjCDeclaration: false
30
-  AfterStruct:     false
31
-  AfterUnion:      false
32
-  BeforeCatch:     false
33
-  BeforeElse:      false
34
-  IndentBraces:    false
35
-BreakBeforeBinaryOperators: None
36
-BreakBeforeBraces: Attach
37
-BreakBeforeTernaryOperators: true
38
-BreakConstructorInitializersBeforeComma: false
39
-ColumnLimit:     120
40
-CommentPragmas:  '^ IWYU pragma:'
41
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
42
-ConstructorInitializerIndentWidth: 4
43
-ContinuationIndentWidth: 4
44
-Cpp11BracedListStyle: true
45
-DerivePointerAlignment: false
46
-DisableFormat:   false
47
-ExperimentalAutoDetectBinPacking: false
48
-ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
49
-IncludeCategories: 
50
-  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
51
-    Priority:        2
52
-  - Regex:           '^(<|"(gtest|isl|json)/)'
53
-    Priority:        3
54
-  - Regex:           '.*'
55
-    Priority:        1
56
-IndentCaseLabels: false
57
-IndentWidth:     4
58
-IndentWrappedFunctionNames: false
59
-KeepEmptyLinesAtTheStartOfBlocks: true
60
-MacroBlockBegin: ''
61
-MacroBlockEnd:   ''
62
-MaxEmptyLinesToKeep: 1
63
-NamespaceIndentation: None
64
-ObjCBlockIndentWidth: 2
65
-ObjCSpaceAfterProperty: false
66
-ObjCSpaceBeforeProtocolList: true
67
-PenaltyBreakBeforeFirstCallParameter: 19
68
-PenaltyBreakComment: 300
69
-PenaltyBreakFirstLessLess: 120
70
-PenaltyBreakString: 1000
71
-PenaltyExcessCharacter: 1000000
72
-PenaltyReturnTypeOnItsOwnLine: 60
73
-PointerAlignment: Right
74
-ReflowComments:  true
75
-SortIncludes:    true
76
-SpaceAfterCStyleCast: false
77
-SpaceBeforeAssignmentOperators: true
78
-SpaceBeforeParens: ControlStatements
79
-SpaceInEmptyParentheses: false
80
-SpacesBeforeTrailingComments: 1
81
-SpacesInAngles:  false
82
-SpacesInContainerLiterals: true
83
-SpacesInCStyleCastParentheses: false
84
-SpacesInParentheses: false
85
-SpacesInSquareBrackets: false
86
-Standard:        Cpp11
87
-TabWidth:        8
88
-UseTab:          Never
89
-...
90
-

+ 17
- 0
data/script/debug.s Zobrazit soubor

@@ -0,0 +1,17 @@
1
+#include <script/language.h>
2
+
3
+.text
4
+.thumb
5
+.align 2
6
+
7
+.global debug_script
8
+debug_script:
9
+    lock
10
+    faceplayer
11
+    giveitem 1 1 0
12
+    msgbox debug 6
13
+    release
14
+    end
15
+
16
+debug:
17
+    .string LAN_DE "debug script"

+ 1
- 1
sots-private

@@ -1 +1 @@
1
-Subproject commit c3d50f2675c5d4b707b0581610d7dcfa10457b2b
1
+Subproject commit aff5be521a19c96566bbe4016438c69f1a9a4bfa

+ 4
- 0
src/include/script/language.h Zobrazit soubor

@@ -175,7 +175,11 @@ callstd \msgbox_callstd
175 175
 .macro giveitem giveitem_item:req giveitem_quantity:req giveitem_messagetyp:req
176 176
 copyvarifnotzero 0x8000 \giveitem_item
177 177
 copyvarifnotzero 0x8001 \giveitem_quantity
178
+setvar 0x5006 10
179
+special 0x68
178 180
 callstd \giveitem_messagetyp
181
+setvar 0x5006 11
182
+special 0x68
179 183
 .endm
180 184
 
181 185
 .macro giveitem2 giveitem2_item:req giveitem2_quantity:req giveitem2_song:req

+ 56
- 6
src/interface/show_item.c Zobrazit soubor

@@ -1,11 +1,46 @@
1 1
 #include <pokeagb/pokeagb.h>
2
+#include <agb_debug.h>
2 3
 
3
-const struct OamData item_oam = {.size = 2};
4
+#define SHOW_ITEM_TAG 0x1340
5
+
6
+const struct OamData item_oam = {.size = 2, .shape = 0, .priority = 0};
7
+
8
+/*
9
+ * Need to fix the alignment to follow a 24x24 pattern
10
+ * 
11
+ * from
12
+ * 
13
+ * # # # #
14
+ * # # # #
15
+ * # X X X
16
+ * X X X X
17
+ * 
18
+ * to
19
+ * 
20
+ * # # # X
21
+ * # # # X
22
+ * # # # X
23
+ * X X X X
24
+ * 
25
+ * where # is a valid data tile
26
+ */
27
+void item_fix_alignment(u8* buffer, u8* dst)
28
+{
29
+    memcpy(32*0 + dst, 32*0 + buffer, 3*32);
30
+    memcpy(32*4 + dst, 32*3 + buffer, 3*32);
31
+    memcpy(32*8 + dst, 32*6 + buffer, 3*32);
32
+}
4 33
 
5 34
 void show_item_load_gfx(u16 item)
6 35
 {
7
-    struct SpriteTiles tiles = {.data = item_gfx_table[item].gfx, .size = 32*16, .tag = 0x1340};
8
-    struct SpritePalette pal = {.data = item_gfx_table[item].pal, .tag = 0x1340};
36
+    u8* temp_buffer = malloc_and_clear(32*16);
37
+    u8* item_gfx_buffer = malloc_and_clear(32*16);
38
+    LZ77UnCompWram(item_gfx_table[item].gfx, temp_buffer);
39
+    item_fix_alignment(temp_buffer, item_gfx_buffer);
40
+
41
+    struct SpriteTiles tiles = {.data = item_gfx_buffer, .size = 32*16, .tag = SHOW_ITEM_TAG};
42
+    struct SpritePalette pal = {.data = item_gfx_table[item].pal, .tag = SHOW_ITEM_TAG};
43
+
9 44
     struct Template template = {
10 45
         .tiles_tag = 0x1340,
11 46
         .pal_tag = 0x1340,
@@ -15,7 +50,22 @@ void show_item_load_gfx(u16 item)
15 50
         .rotscale = SPRITE_NO_ROTSCALE,
16 51
         .callback = oac_nullsub
17 52
     };
18
-    gpu_tile_obj_decompress_alloc_tag_and_upload(&tiles);
19
-    gpu_pal_obj_alloc_tag_and_apply(&pal);
20
-    template_instanciate_forward_search(&template, 100,100,0);
53
+
54
+    gpu_tile_obj_alloc_tag_and_upload(&tiles); //has already been decompressed above
55
+    gpu_pal_decompress_alloc_tag_and_upload(&pal); //this has not
56
+    var_800A = template_instanciate_forward_search(&template, 210,140,0);
57
+    free(temp_buffer);
58
+    free(item_gfx_buffer);
59
+}
60
+
61
+void hide_item_unload_gfx(void)
62
+{
63
+    obj_delete_and_free(&objects[var_800A]);
64
+    gpu_pal_free_by_tag(SHOW_ITEM_TAG);
65
+}
66
+
67
+void sp_show_item(void)
68
+{
69
+    dprintf("entering sp_show_item");
70
+    show_item_load_gfx(var_load(0x8001));
21 71
 }

+ 6
- 1
src/specials/custom_specials.c Zobrazit soubor

@@ -65,6 +65,8 @@ void sp_clear_variables();
65 65
  */
66 66
 void sp_random_number();
67 67
 
68
+void sp_show_item(void);
69
+
68 70
 extern void sp_batchmaptile(void);
69 71
 
70 72
 void get_text_pointer_from_lookup();
@@ -73,6 +75,8 @@ void sp_check_tileset();
73 75
 
74 76
 void sp_set_rival(void);
75 77
 
78
+void hide_item_unload_gfx(void);
79
+
76 80
 extern void sp_crystal_fade(void);
77 81
 
78 82
 extern pchar name_rival_male[5];
@@ -80,9 +84,10 @@ extern pchar name_rival_female[5];
80 84
 
81 85
 /* === STATICS === */
82 86
 
83
-static special_func special_routines[10] = {
87
+static special_func special_routines[12] = {
84 88
     NULL,         cam_sp_move_camera, sp_init_script,  NULL, NULL,
85 89
     sp_random_number, sp_check_tileset,   sp_batchmaptile, sp_crystal_fade, sp_set_rival,
90
+    sp_show_item, hide_item_unload_gfx
86 91
 };
87 92
 
88 93
 /* === IMPLEMENTATIONS === */